gpt4 book ai didi

postgresql - 使用 to_timestamp 函数解析 Twitter 时间戳时出现问题

转载 作者:行者123 更新时间:2023-11-29 13:04:14 25 4
gpt4 key购买 nike

我通过流式 API 下载了 Twitter 数据,并希望将数据导入 Postgres(9.3 版)以进行一些地理分析。

解析 json 数据有效,但我无法将 Twitter 时间设置为正确的时间戳。这是来自 json 的时间戳:

Wed Oct 09 10:31:05 +0000 2013

我试着这样解析它:

select to_timestamp('Wed Oct 09 10:31:05 +0000 2013', 'DY Mon DD HH24:MI:SS YYYY')

但它只有在我去掉 +0000 部分时才有效。

如果你能帮我解决这个问题就太好了。

最佳答案

这似乎有效,如果所有时间都是 +0000:

test=# select to_timestamp('Wed Oct 09 10:31:05 +0000 2013', 'DY Mon DD HH24:MI:SS +0000 YYYY');
to_timestamp
------------------------
2013-10-09 10:31:05+02
(1 row)

如果不是,那似乎也没什么大不了:

test=# select to_timestamp('Wed Oct 09 10:31:05 +0200 2013', 'DY Mon DD HH24:MI:SS +0000 YYYY');
to_timestamp
------------------------
2013-10-09 10:31:05+02
(1 row)

test=# select to_timestamp('Wed Oct 09 10:31:05 +0200 2013', 'DY Mon DD HH24:MI:SS xxxx YYYY')::timestamp without time zone;
to_timestamp
---------------------
2013-10-09 10:31:05
(1 row)

关于postgresql - 使用 to_timestamp 函数解析 Twitter 时间戳时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19376666/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com