将一时间戳字段默认值设为0001-01-01 00:00:00 UTC,在timezone为东8区的数据库中字段值显示为:
0001-01-01 08:05:43+08:05:43
Google后找到如下解释:
0001-01-01 00:00:00 UTC. And that is indeed 0001-01-01 08:05:43 in your local time zone (whatever that may be, probably Asia/Shanghai
or somewhere near that). When you console.log
a Date
, it displays the date in your local time zone. The Date
value is correct. It's just displayed in a different format.
The extra 5 minutes and 43 seconds is because at the year AD 1, time zones have not been standardised, and the local mean time offset from UTC at your location is +08:05:43.
也就是说在0001年的时候还没有标准化时区。经自行测试发现标准化时区是从1901年1月1日开始的,之前都是LMT(Local Mean TIme):
1900-01-01 00:00:00 UTC --> 1900-01-01 08:05:43+08:05:43
1901-01-01 00:00:00 UTC --> 1901-01-01 08:00:00+08
所以想避免为时间显示做额外的处理,可将默认时间设为1901-01-01 00:00:00 UTC。
标签:UTC,00,01,0001,08,43,Timezone From: https://www.cnblogs.com/zhangzhihui/p/17877446.html