在 Cassandra 中将时间转换为 12 小时格式
Converting time to 12 hour format in Cassandra
我正在使用 Cassandra 3.11.2。
Cassandra 以 24 小时制显示日期和时间 format.How 我要将其更改为标准的 12 小时格式吗?
cqlsh
中的时间打印由 ~/.cassandra/cqlshrc
的 [ui]
部分中的 time_format
设置控制。格式字符串对应于 Python 的 time.strftime
format。所以你需要改成这样(%I
- 12 小时格式,%p
- AM/PM 指标):
[ui]
time_format = %Y-%m-%d %I:%M:%S %p
示例:
cqlsh> create table test.tm(id int primary key, tm timestamp);
cqlsh> insert into test.tm(id,tm) values(1, '2018-06-18 18:30:55Z');
cqlsh> SELECT * from test.tm;
id | tm
----+------------------------
1 | 2018-06-18 08:30:55 PM
(1 rows)
我正在使用 Cassandra 3.11.2。 Cassandra 以 24 小时制显示日期和时间 format.How 我要将其更改为标准的 12 小时格式吗?
cqlsh
中的时间打印由 ~/.cassandra/cqlshrc
的 [ui]
部分中的 time_format
设置控制。格式字符串对应于 Python 的 time.strftime
format。所以你需要改成这样(%I
- 12 小时格式,%p
- AM/PM 指标):
[ui]
time_format = %Y-%m-%d %I:%M:%S %p
示例:
cqlsh> create table test.tm(id int primary key, tm timestamp);
cqlsh> insert into test.tm(id,tm) values(1, '2018-06-18 18:30:55Z');
cqlsh> SELECT * from test.tm;
id | tm
----+------------------------
1 | 2018-06-18 08:30:55 PM
(1 rows)