Jas*_*med 5 postgresql datetime json
有什么办法可以将日期时间格式化为RFC3339Nano例如:2006-01-02T15:04:05.999999999Z07:00 在PostgreSQL 9.3或9.5中?
我尝试了to_char。但没有文件如何处理 T,Z,+07:00,-07:00等。
我能到达的最近的是
v2=# select to_char(current_timestamp, 'YYYY-MM-DD HH:MI:SS.MSOF');
to_char
----------------------------
2016-05-08 12:16:14.493+04
Run Code Online (Sandbox Code Playgroud)
这是Postgres 9.3中的默认JSON输出格式datetime。请看下面。
psql (9.5.1, server 9.3.6)
Type "help" for help.
fetchrdb=> select to_json(current_timestamp);
to_json
---------------------------------
"2016-05-08 11:58:04.844548+04"
(1 row)
Run Code Online (Sandbox Code Playgroud)
对于Postgres 9.5的JSON编码输出,RFC3339Nano例如:
psql (9.5.1)
Type "help" for help.
v2=# select to_json(current_timestamp);
to_json
------------------------------------
"2016-05-08T11:59:17.121411+04:00"
Run Code Online (Sandbox Code Playgroud)
我找不到使用postgres 9.3或9.5将datetime格式化为RFC3339Nano的选项to_char。
http://www.postgresql.org/docs/9.5/static/functions-formatting.html
您是否使用任何隐藏的选项/功能来实现相同的目的?关于任何帮助表示赞赏。
| 归档时间: |
|
| 查看次数: |
876 次 |
| 最近记录: |