postgresql – Postgres UTC日期格式和纪元演员,签名反转

postgresql – Postgres UTC日期格式和纪元演员,签名反转,第1张

概述有人能解释我这种反转,我迷失在这里…… SELECT EXTRACT(EPOCH FROM '01-01-1970 00:00:00 UTC+01'::timestamp with time zone) => 3600 SELECT EXTRACT(EPOCH FROM '1970-01-01 00:00:00+01'::timestamp with time zone) => -3600 Pos 有人能解释我这种反转,我迷失在这里……

SELECT EXTRACT(EPOCH FROM '01-01-1970 00:00:00 UTC+01'::timestamp with time zone)

=> 3600

SELECT EXTRACT(EPOCH FROM '1970-01-01 00:00:00+01'::timestamp with time zone)

=> -3600

Postgres 8.3.14

解决方法 这个

1970-01-01 00:00:00+01

是一个ISO 8601 timestamp with a +1 hour offset和1意味着格林威治以东.这些中的抵消

01-01-1970 00:00:00 UTC+011970-01-01 00:00:00 UTC+011970-01-01 00:00:00 XXX+011970-01-01 00:00:00 HAHA+011970-01-01 00:00:00 Pancakes+01

将被解释为POSIX style timezones,其中1表示格林威治以西:

Postgresql will accept POSIX-style time zone specifications of the form STDoffset or STDoffsetDST,where STD is a zone abbreviation,offset is a numeric offset in hours west from UTC

那些甚至带来警告:

One should be wary that the POSIX-style time zone feature can lead to silently accepting bogus input,since there is no check on the reasonableness of the zone abbreviations. For example,SET TIMEZONE TO FOObar0 will work,leaving the system effectively using a rather peculiar abbreviation for UTC. Another issue to keep in mind is that in POSIX time zone names,positive offsets are used for locations west of Greenwich. Everywhere else,Postgresql follows the ISO-8601 convention that positive timezone offsets are east of Greenwich.

注意西与东的差异.

总结

以上是内存溢出为你收集整理的postgresql – Postgres UTC日期格式纪元演员,签名反转全部内容,希望文章能够帮你解决postgresql – Postgres UTC日期格式和纪元演员,签名反转所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1160980.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存