2👍
Use the Django template defaultfilters to format your dates in Python code.
from django.template.defaultfilters import date as _date
_date(datetime_object, "%H:%M")
And, maybe related: Django cannot reliably use alternate time zones in a Windows. See documentation.
0👍
I don’t think Turkey has anything to do with it.
My guess is that the one-hour difference you’re seeing is between the Paris timezone—which is being used, by default, to interpret and display dates—and UTC—which is being used to store the datetime
, and which is the timezone of the datetime
returned from the database.
If that’s correct, then you can just use django.utils.timezone.localtime
to convert the datetime
to the current time zone (which by default will be TIME_ZONE
):
localtime(beginning_date).strftime("%H:%M")
- [Answered ]-GUI in web (Django) for Python script
- [Answered ]-Error message "Still can't get my hands on win32ui" when setting up new Django project
Source:stackexchange.com