如何将datetime对象转换为自Python中的EIRCH(Unix Time)以来的毫秒?我有一只Pythondatetime对象,希望将其转换为Unix Time,或自1970年代以来的秒/毫秒。我该怎么做?
3 回答

叮当猫咪
TA贡献1776条经验 获得超12个赞
import datetime epoch = datetime.datetime.utcfromtimestamp(0)def unix_time_millis(dt): return (dt - epoch).total_seconds() * 1000.0
添加回答
举报
0/150
提交
取消