Last active
January 3, 2018 17:10
-
-
Save jorilallo/4484793 to your computer and use it in GitHub Desktop.
How to create, store and return timestamps in UTC with Django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.utils.timezone import now as utcnow | |
| from calendar import timegm as epoch | |
| # Store in model | |
| created = models.DateTimeField(default=utcnow()) | |
| # Get in UTC Epoch | |
| epoch(created.timetuple()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment