我是hbase的新手,目前我正在使用hbase-1.2.6。我使用freebase包使用python脚本连接到hbase。我的问题是: 有人可以让我知道如何解码时间戳值,每当我们在表格中放入任何记录时会自动插入该值吗?
1.what is the exact interpretation of timestamp value in hbase?
2.can we convert this timestamp value to yy-mm-dd-hh:mm:ss format?
答案 0 :(得分:0)
时间戳值是自纪元(1970年1月1日UTC)以来的毫秒数。您可以使用python datetime
模块来操作它。例如:
from datetime import datetime as dt
print (dt.fromtimestamp(1511356398000 / 1000))
Output:
2017-11-22 07:13:18
结果是我当地时区的datetime
个对象。 (美国中部)datetime.fromtimestamp
方法需要浮点值,即自纪元以来的秒数,因此将时间(以毫秒为单位)除以1000.
Here是datetime
模块参考。