Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
668 views
in Technique[技术] by (71.8m points)

cassandra - specify cqlsh output timezone

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

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.

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.

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

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)

and:

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...