Skip to content

Instantly share code, notes, and snippets.

@eupharis
Created October 23, 2013 23:05
Show Gist options
  • Save eupharis/7128414 to your computer and use it in GitHub Desktop.
Save eupharis/7128414 to your computer and use it in GitHub Desktop.
A nice way to get Python strings to be that nice default Django template datetime format.
from django.template import defaultfilters
from django.utils import timezone
localtime = timezone.template_localtime(my_date)
template_style_date = defaultfilters.date(localtime, settings.DATETIME_FORMAT)
# settings.DATETIME_FORMAT is the Django default by default, but can be overwritten in your settings.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment