Skip to content

Instantly share code, notes, and snippets.

@jorilallo
Last active January 3, 2018 17:10
Show Gist options
  • Select an option

  • Save jorilallo/4484793 to your computer and use it in GitHub Desktop.

Select an option

Save jorilallo/4484793 to your computer and use it in GitHub Desktop.
How to create, store and return timestamps in UTC with Django
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