我是 hbase 新手,目前我正在使用 hbase-1.2.6。我使用happybase包使用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?
时间戳值是自纪元(UTC 时间 1970 年 1 月 1 日)以来的毫秒数。您可以使用 pythondatetime
模块来操作它。例子:
from datetime import datetime as dt
print (dt.fromtimestamp(1511356398000 / 1000))
Output:
2017-11-22 07:13:18
结果是datetime
我当地时区的一个对象。(美国中部)该datetime.fromtimestamp
方法需要一个浮点值,即自纪元以来的时间(以秒为单位),因此以毫秒为单位的时间除以 1000。
这是datetime
模块参考。