4 ms·
Better still, just store dates as ISO-8601 standard YYYY-MM-DD format. Mucking about with timezones at all inevitably introduces bugs when you're just talking
by Falkon1313 4y ago
Better still, just store dates as ISO-8601 standard YYYY-MM-DD format. Mucking about with timezones at all inevitably introduces bugs when you're just talking about dates.
Of course, times sometimes do need timezones. But calendar dates (like Christmas, or your birthday) almost never do and having things automagically do adjustments based on that and give the wrong results is just a pain.
That's one thing I don't like about many standard libraries. They'll have a DateTime object that does all kinds of automagic stuff for you (or against you), but no concept of just a date itself. Many bugs occur between 2300 and 0100 due to that (and sometimes between 1100 and 1300 because people try to compensate for the buggy adjustments by setting the unwanted time component to noon).
Another problem arises when the server's timezone is set to X, the database's timezone is Y, the software's timezone is Z, and one user's entering data in timezone A while another is reading it in timezone B - and all of the software parts along the way are each trying to automagically adjust it. A good reason we should just all switch to UTC and drop the idea of timezones entirely.