我得到的答案是其余的Epoch时间格式
start_time = 1234566
end_time = 1234578
Run Code Online (Sandbox Code Playgroud)
我想在MySQL格式时转换那个纪元秒,这样我就可以在MySQL数据库中存储差异.
我试过了:
>>> import time
>>> time.gmtime(123456)
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=2, tm_hour=10, tm_min=17, tm_sec=36, tm_wday=4, tm_yday=2, tm_isdst=0)
Run Code Online (Sandbox Code Playgroud)
以上结果不是我所期待的.我希望它像
2012-09-12 21:00:00
Run Code Online (Sandbox Code Playgroud)
请建议我如何实现这一目标?
另外,为什么我收到TypeError: a float is required了
>>> getbbb_class.end_time = 1347516459425
>>> mend = time.gmtime(getbbb_class.end_time).tm_hour
Traceback (most recent call last):
...
TypeError: a float is required
Run Code Online (Sandbox Code Playgroud) 要获取JavaScript中的时间戳,我们使用
var ts = new Date().getTime()
Run Code Online (Sandbox Code Playgroud)
datetime到目前为止,将它转换为Python的正确方法是什么,我使用以下代码
>>> jsts = 1335205804950
>>> dt = datetime.datetime.fromtimestamp(jsts/1000)
>>> dt
datetime.datetime(2012, 4, 24, 0, 30, 4)
Run Code Online (Sandbox Code Playgroud)
我将时间戳除以1000,因为我得到了错误
ValueError Traceback (most recent call last)
1 d = datetime.datetime.fromtimestamp(a)
ValueError: year is out of range
Run Code Online (Sandbox Code Playgroud)
苏丹.