Created
October 23, 2013 23:05
-
-
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.
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.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