📜  将日期时间转换为时间戳 django - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:20.727000             🧑  作者: Mango

代码示例2
# Format it into seconds
>>> datetime.datetime(2012,04,01,0,0).strftime('%s')
'1333234800'

# OR, subtract the time with 1 Jan, 1970 i.e start of epoch time
# get the difference of seconds using `total_seconds()`
>>> (datetime.datetime(2012,04,01,0,0) - datetime.datetime(1970,1,1)).total_seconds()
1333238400.0