0

I can open a plain Python console and run:

>>> from datetime import datetime
>>> datetime.now().strftime('%H:%M')
'01:21'

This is correct.

When I do the same in ./manage.py shell, however, I get different results:

>>> from datetime import datetime
>>> datetime.now().strftime('%H:%M')
'23:21'

This is wrong. Why is that? I though it might be related to the timezone, so I checked date time.now().tzinfo, which, however, is None in both cases. I also tried setting USE_TZ = False in settings.py but it doesn't make a difference (it was on True by default).

All I need is local time. How to force Django to operate likewise a regular Python console?

theV0ID
  • 4,172
  • 9
  • 35
  • 56

0 Answers0