postgres默认时区 [英] postgres default timezone

查看:159
本文介绍了postgres默认时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了PostgreSQL 9,它显示的时间比服务器时间晚了1个小时.

I installed PostgreSQL 9 and the time it is showing is 1 hour behind the server time.

运行Select NOW()显示:2011-07-12 11:51:50.453842+00

服务器日期显示:Tue Jul 12 12:51:40 BST 2011

晚了1小时,但phppgadmin中显示的时区为:TimeZone Etc/GMT0

It is 1 hour behind but the timezone shown in phppgadmin is: TimeZone Etc/GMT0

我尝试进入postgresql.conf并设置

时区= GMT

timezone = GMT

然后重新启动但没有任何更改.

then running a restart but no change.

我认为它会使用服务器时区的任何想法,但显然不会吗?!

Any ideas I thought it would have just used the server timezone but obviously not?!

解决方案!: 之前我确实设置了GMT,但已经晚了一个小时.经过搜索后,我需要将其设置为Europe/London.这考虑到英国夏令时+1小时,格林尼治标准时间不考虑!

SOLUTION!: I did set to GMT before and it was an hour behind. after searching around turns out that I needed to set it to Europe/London. This takes into account the +1 hour in British summer time, GMT does not!

推荐答案

时区是会话参数.因此,您可以更改当前会话的时区.

The time zone is a session parameter. So, you can change the timezone for the current session.

请参见文档.

set timezone TO 'GMT';


或者,更严格地遵循SQL标准,请使用 SET TIME ZONE 命令.请注意时区"两个词,其中上面的代码使用单个词时区".


Or, more closely following the SQL standard, use the SET TIME ZONE command. Notice two words for "TIME ZONE" where the code above uses a single word "timezone".

SET TIME ZONE 'UTC';

文档解释了区别:

SET TIME ZONE扩展了SQL标准中定义的语法.该标准仅允许数字时区偏移,而PostgreSQL允许更灵活的时区规范. SET的所有其他功能都是PostgreSQL扩展.

SET TIME ZONE extends syntax defined in the SQL standard. The standard allows only numeric time zone offsets while PostgreSQL allows more flexible time-zone specifications. All other SET features are PostgreSQL extensions.

这篇关于postgres默认时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆