[Django]-How to work with time.strftime in django 1.6

5👍

Maybe you’re dealing with UTC time. Convert it to local time before call strftime:

>>> from django.utils import timezone
>>> now = timezone.now()
>>> now.strftime('%H:%M:%S')
'13:23:52'
>>> timezone.localtime(now).strftime('%H:%M:%S')
'22:23:52'

See Time zones | Django documentation.

Leave a comment