specify cqlsh output timezone

前端 未结 4 2062
一个人的身影
一个人的身影 2020-12-17 23:12

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

4条回答
  •  悲&欢浪女
    2020-12-17 23:16

    Thanks for the question. Here is just an alternative way, which is do some date operation after you fetch the data using "datetime.timedelta()". You can calculate the offset time from UTC, and then do a date adjust. Just for your reference.

    >>> import datetime 
    >>> offset = -10 # in hours
    >>> original = '08/19/2015 10:59' 
    >>> adjusted = datetime.datetime.strptime(original, '%m/%d/%Y %H:%M') + datetime.timedelta(hours=offset) 
    >>> print adjusted.strftime('%m/%d/%Y %H:%M') 
        08/19/2015 00:59
    

提交回复
热议问题