在Cassandra中将时间转换为12小时格式

时间:2018-07-05 13:14:36

标签: cassandra cqlsh

我正在使用Cassandra 3.11.2。 Cassandra以24小时制显示日期和时间。如何将其更改为标准的12小时制?

1 个答案:

答案 0 :(得分:3)

cqlshtime_format部分的[ui]设置控制着~/.cassandra/cqlshrc中时间的打印。格式字符串对应于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)
相关问题