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

查看:1082
本文介绍了指定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 | Cassandra 2.0.6 | CQL spec 3.1.1

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

感谢

推荐答案

环境变量以显示时区:

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天全站免登陆