3 ms·
Remember if you store local date times in your DB it may be hard or impossible to get back the UTC later.
by quickthrower2 8y ago
Remember if you store local date times in your DB it may be hard or impossible to get back the UTC later.
- deleted 8y ago[deleted]
- koliber 8y agoIt should be possible in most practical situations. This is assuming you are storing the timezone correctly. You can always look at the date component of the timezone, look it up in a DB like the Olson DB to see what the UTC offset was on that date, and then apply that offset to get the datetime in UTC. There are a few relatively small periods in time when that mapping is not one-to-one. Then it is not possible without additional information. That being said, do everyone a solid and store your date times in the DB in UTC, in a field type that explicitly supports date times with timezones.
- jsjohnst 8y ago> field type that explicitly supports date times with timezones So as a string then in MySQL? ;)
- gpvos 8y agoYou should store local date-times. But also the timezone name (not just the time offset!). Unless you are logging, then you can store UTC.
- jrockway 8y agoUTC is not a good format for storage either. It has leap seconds, resulting in some seconds that happen twice or some seconds that happen never; you can't just subtract two times from each other and get the duration, for example. Use TAI.