3 ms·
How to write timezone friendly django application using MySQL
- pxlpshr 16y agoWe do it without storing a user's time zone via jQuery and a custom script that converts all UTC time stamps on a page to the local time setting of their computer. This works well for us because we have travelers who use the service through a variety of time zones. The second touch point is our iPhone app, and the SDK has built-in support for converting UTC to the client time.
- zokier 16y ago"UTC used to be called GMT." Not exactly. iirc UTC is based on atomic clocks while GMT is based on astronomy. The whole time measurement system is quite complex and messy. But in most cases it probably is fair to call UTC and GMT equivalent.
- alexdong 16y agoYou're right. UTC is within 0.9 sec from GMT. Nowadays, it seems like GMT and UTC are two interchangeable names, who'd expect to think they were actually so difference in terms of how each gets calculated.
- js2 16y agohttp://www.iers.org/nn_10398/IERS/EN/Science/EarthRotation/UT1LOD.html?__nnn=true http://www.iers.org/nn_10398/IERS/EN/Science/EarthRotation/U...
- IgorPartola 16y agoThe basic steps for this are: store everything in UTC, do all arithmetic in UTC, store user's timezone info and convert to that at the last second. Python does not have built-in TZ information so you need pytz installed.
- MicahWedemeyer 16y agoStoring in UTC goes for all languages, all applications, all realms. Computer Time = UTC Think of converting to local timezone as the same as adding commas to a number to make it look nicer. It's useful for humans but the computer doesn't care.
- IgorPartola 16y agoExactly. I also prefer to store things in a UNIX timestamp. Even with it's limitations, it's still the easiest way to do time arithmetic.