1

I've spent a lot of wasted time on figuring out timezone issues. I know best practice is to store everything as UTC... but I'm at the point where I don't trust UTC timezone is always preserved.

So my question, is it safe and/or cheaper to store dates as epoch milliseconds in the database instead of a Date type to avoid headaches of whether or not server libraries will convert and stores timezones properly? I found that storing as milliseconds basically fools any servers or even the database to not convert.

Jason Washo
  • 536
  • 6
  • 22
  • 1
    Probably useful: http://stackoverflow.com/questions/2532729/daylight-saving-time-and-time-zone-best-practices – assylias Oct 24 '16 at 19:52

1 Answers1

0

I have found it beneficial to think of time zone information as an input/output trait only. I consider it when reading time information, store/process pure time, and only add time zone when formatting for output.

In other words, a moment is never in a time zone. A moment is an absolute point in time that has various names depending on the time zone you are looking at it from.

zoul
  • 102,279
  • 44
  • 260
  • 354