#31638: On Mysql/Sqlite, db.models.functions.Now uses wrong timezone
-------------------------------------+-------------------------------------
Reporter: Matthijs Kooijman | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Adam (Chainz) Johnson):
> On May 17, 2018, the official AWS Cloud Twitter account tweeted out an
article with the following caption, “Change the timezone of your Amazon
RDS instance to local time.” I hit the roof immediately and began ranting
about it and railing against that tweet in particular.
>
> I believe this is the first time that me yelling at AWS in public hit
semi-viral status. My comment, to be precise, was absolutely do not do
this. UTC is the proper server timezone unless you want an incredibly
complex problem after you scale. Fixing this specific problem has bought
consultants entire houses in San Francisco. Now, I stand by that criticism
and I maintain that your databases should be in UTC at all times, as
should the rest of your servers.
Corey Quinn - https://www.lastweekinaws.com/podcast/aws-morning-brief
/whiteboard-confessional-you-down-with-utc-yeah-you-know-me/
Like Corey, I strongly believe in only using UTC for all servers and data
at rest. The rest of that podcast (with transcript) shows why.
I think even adding system checks to Django to warn if you're using UTC
would be justified.
I'm not hopeful of any approach to trying to use the same timezone in both
the database and Django. Even if you get the same name, it can mean a
different offset. The timezone database changes whenever any government
feels like an adjustment and there's no good way of guaranteeing the
database (normally from the OS) has the same one as Django (pytz). See the
release history on pytz https://pypi.org/project/pytz/#history .
> Then, I'm not too keen on making `Now` cleverer. The whole point of the
functions in db.models that they proxy down transparently to what the DB
provides.
I agree Carlton. But perhaps we should have a warning note in the `Now`
docs about timezones, and a `UtcNow()` database function?
--
Ticket URL: <https://code.djangoproject.com/ticket/31638#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/074.6f96f9f8259f6a61abb4a770dcc630b2%40djangoproject.com.