10时间戳获取方法:
>>> import time
>>> t = time.time()
>>> print t
>>> print int(t)
强制转换是直接去掉小数位。
2、13位时间戳获取方法:
(1)默认情况下python的时间戳是以秒为单位输出的float
>>> import time
>>> time.time()
通过把秒转换毫秒的方法获得13位的时间戳:
import time
millis = int(round(time.time() * 1000))
print millis
round()是四舍五入。
(2)
import time
current_milli_time = lambda: int(round(time.time() * 1000))
>>> current_milli_time()
13位时间 戳转换成时间:
>>> import time
>>> now = int(round(time.time()*1000))
>>> now02 = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(now/1000))
>>> now02