如何获得时间偏移量(差异)b/w time.strftime 和 datetime.datetime?
How to get Time offset (diffrence) b/w time.strftime and datetime.datetime?
我正在以 unix(毫秒)为单位获取时间输入,并希望获得时差 b/w 给定值和我遵循的当前时间。第一次将 posix 转换为人类可读,然后尝试减去 2 个值,但 -
与 str.
不匹配
/1000 is for millisecond reduction
t = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1496814300000/1000))
k = datetime.datetime.now()
j = k -t
print j
在此处找到解决方案
how to convert a string date into datetime format in python?
strptime是将字符串转换成datetime的关键
尝试将您的时间戳直接转换为日期时间对象:
import datetime
t = datetime.datetime.fromtimestamp(1496814300000/1000)
k = datetime.datetime.now()
j = k - t
print(j)
我正在以 unix(毫秒)为单位获取时间输入,并希望获得时差 b/w 给定值和我遵循的当前时间。第一次将 posix 转换为人类可读,然后尝试减去 2 个值,但 -
与 str.
/1000 is for millisecond reduction
t = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1496814300000/1000))
k = datetime.datetime.now()
j = k -t
print j
在此处找到解决方案
how to convert a string date into datetime format in python?
strptime是将字符串转换成datetime的关键
尝试将您的时间戳直接转换为日期时间对象:
import datetime
t = datetime.datetime.fromtimestamp(1496814300000/1000)
k = datetime.datetime.now()
j = k - t
print(j)