指定 cqlsh 输出时区 [英] specify cqlsh output timezone

查看:32
本文介绍了指定 cqlsh 输出时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 cassandra 中有一个表,其数据类型为时间戳.我正在使用 cqlsh 从数据库中获取数据,并希望更改时间戳列输出的输出格式.我研究了一下,发现我可以通过更改以下文件来更改时间戳输出格式:

I have a table in cassandra with a datatype of timestamp. i am using cqlsh to get data out of the database and wanted to change the output format for how my timestamp column output looks like. I researched around and found that i can change the timestamp output format by making changes to the following file:

  • ~/.cassandra/cqlshrc

但我了解到我可以做的唯一更改是时间元素,我无法输出以在不同的时区(例如 UTC)显示我的时间戳.它始终以我的本地时区显示时间戳.

But i learnt that the only change i can make is the time elements, i cannot make the output to display my timestamps in a different timezone(say UTC). It always displays the timestamps in my local timezone.

我想知道是否有办法让 cqlsh 在我想要的时区或至少在 UTC 区域中显示时间戳.
任何帮助或指示表示赞赏.

I wanted to know if there is a way i could make cqlsh display timestamp in my desired time zone, or atleast in UTC zone.
Any help or pointers are appreciated.

我正在使用以下版本:
cqlsh 4.1.1 |卡桑德拉 2.0.6 |CQL 规范 3.1.1

I'm using the following versions:
cqlsh 4.1.1 | Cassandra 2.0.6 | CQL spec 3.1.1

谢谢

推荐答案

您可以更改环境变量以获取显示时区:

You can change your environment variable to get show timezone:

TZ=America/Los_Angeles cqlsh -k mpj `hostname` -e 'select time from userbehavior limit 3'

 time
--------------------------
 2015-02-15 21:17:03-0800
 2015-02-15 18:16:21-0800
 2015-02-15 00:04:52-0800

(3 rows)

和:

TZ=UTC cqlsh -k mpj `hostname` -e 'select time from userbehavior limit 3'

 time
--------------------------
 2015-02-16 05:17:03+0000
 2015-02-16 02:16:21+0000
 2015-02-15 08:04:52+0000

(3 rows)

这篇关于指定 cqlsh 输出时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆