如何在 UTC 中显示 current_timestamp 以及 postgresql 中的时区?

问题描述 投票:0回答:1

我使用 PostgreSQL 16 并运行以下查询。

select (current_timestamp AT TIME ZONE 'UTC');

返回 UTC 时间,不附加时区。

2024-10-04 18:44:59.34674

如何检索以下输出?

2024-10-04 18:44:59.34674+00:00
postgresql postgresql-16
1个回答
0
投票

将结果投射到

timestamptz
应该可以。

SELECT (current_timestamp AT TIME ZONE 'UTC')::timestamptz;

将会产生

2024-10-04 19:22:29.151774 +00:00
© www.soinside.com 2019 - 2024. All rights reserved.