We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
settings.TIME_ZONE
We always want to deal with UTC, and we want the UTC offset (+00) to be specified explicitly in the database.
+00
With TIME_ZONE = 'America/New_York, it's easy to mistakenly apply a time zone offset to something that was already UTC. Example:
TIME_ZONE = 'America/New_York
>>> u.date_joined = datetime.datetime.now() >>> u.date_joined # this is already UTC! datetime.datetime(2021, 3, 10, 22, 42, 55, 843948) >>> u.save() >>> u.refresh_from_db() >>> u.date_joined # Django assumed it was `America/New_York` and added 5 hours! datetime.datetime(2021, 3, 11, 3, 42, 55, 843948, tzinfo=<UTC>)
With TIME_ZONE = 'UTC', Django behaves the way we want:
TIME_ZONE = 'UTC'
>>> u.date_joined = datetime.datetime.now() >>> u.date_joined datetime.datetime(2021, 3, 10, 22, 44, 0, 673962) >>> u.save() >>> u.refresh_from_db() >>> u.date_joined datetime.datetime(2021, 3, 10, 22, 44, 0, 673962, tzinfo=<UTC>)
Originally posted by @jnm in #677 (comment)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
We always want to deal with UTC, and we want the UTC offset (
+00
) to be specified explicitly in the database.With
TIME_ZONE = 'America/New_York
, it's easy to mistakenly apply a time zone offset to something that was already UTC. Example:With
TIME_ZONE = 'UTC'
, Django behaves the way we want:Originally posted by @jnm in #677 (comment)
The text was updated successfully, but these errors were encountered: