postgres中具有偏移量的时间戳格式

时间:2017-08-12 17:35:34

标签: postgresql datetime timestamp

这真的让我感到难过,而且看起来并不难,但是在postgres 9.6中,我试图用偏移格式化时间戳。

这是我最接近的地方:

SELECT to_char('2017-11-06 00:00:00'::TIMESTAMP WITH TIME ZONE AT TIME ZONE 'America/Vancouver', 'MM/DD/YYYY HH24:MI:SS (OF)');

以上示例获取正确的日期,但偏移量为+00,这是不正确的。

有什么想法吗?

编辑:

此外,如何在功能中设置此功能?以下不起作用:

DECLARE 
    _tz text = 'PST8PDT';
BEGIN
    SET LOCAL TIME ZONE _tz;
...

1 个答案:

答案 0 :(得分:0)

首先设置会话的时区,然后设置时间戳所在的时区。如下所示:

/* load HMVC's MX_Config class */
if ( file_exists(APPPATH . "third_party/MX/Config.php") ) {
    require APPPATH . "third_party/MX/Config.php";
/* otherwise declare MX_Config class */
} else {
    class MX_Config extends CI_Config {}
}


/**
 * Language
 */
class MY_Config extends MX_Config
{
相关问题