How does Linux handle DST (daylight saving time?
How does linux handle daylight saving time (DST)
Does the swich happen instantly, like 3'o clock swiched instantly to 2'o clock ? or it changes slowly I ask you this becouse i have large date base on my servers and if this swich happens instantly one hour on entryes in the data base will pe owerwritten
How can I solve this problem ?
It changes instantly:
Sun 26 Oct 03:59:56 EEST 2014
Sun 26 Oct 03:59:57 EEST 2014
Sun 26 Oct 03:59:58 EEST 2014
Sun 26 Oct 03:59:59 EEST 2014
Sun 26 Oct 03:00:00 EET 2014
Sun 26 Oct 03:00:01 EET 2014
Sun 26 Oct 03:00:02 EET 2014
Sun 26 Oct 03:00:03 EET 2014
Sun 26 Oct 03:00:04 EET 2014
Sun 26 Oct 03:00:05 EET 2014
Sun 26 Oct 03:00:06 EET 2014
Sun 26 Oct 03:00:07 EET 2014
Sun 26 Oct 03:00:08 EET 2014
This is done on a test machine, and it switched immediately.
I ask you this becouse i have large date base on my servers and if this swich happens instantly one hour on entryes in the data base will pe owerwritten
That suggests you're writing the local time into the database. Regardless of how Linux handles it (and I believe it will do as you say, given that that's how time zones work, basically), you almost certainly shouldn't be writing the local time into your database.
If you write the UTC time instead, then you don't need to care about which time zone your systems are set to, or DST effects. You won't get odd situations where an event X which happened after an event Y is actually recorded with an earlier time, nor will there be any ambiguities. You can adjust the stored time to the local time zone when presenting the data should you wish - and you can do that into any time zone you please.
In general, it's recommended to store time data using Coordinated Universal Time (UTC) which doesn't have DST.
Convert from local timezone (and other locale issues) when going into and out of the database. Otherwise you have to store the timezone for for all the times in your database (explicitly or implicitly). Deal with the conversions seem annoying at first, but when you start dealing with users in different timezones you have to do it anyway. So having an a standardized DST-less time is handy in the long run.
As to your current issue, I'm not how to handle it. Since I've always dealt with UTC data, it just doesn't come up.
链接地址: http://www.djcxy.com/p/29406.html上一篇: 什么是“标准”时区缩写?
下一篇: Linux如何处理DST(夏令时?