是否可以使用Python将时间戳转换为毫秒?

时间:2016-07-07 05:42:46

标签: python timestamp

例如,我有一个带有一些时间戳的数组:

(subject_id(PK),subject_name)

转换后我想要一个以毫秒为单位的数字。这可能吗?

1 个答案:

答案 0 :(得分:2)

这应该完成工作:

def toMS(t):
    t = t.split(':')
    t = t[:-1] + t[-1].split('.')
    t = list(map(int, t))
    ms = t[0]*3600*1000 + t[1]*60*1000 + t[2]*1000 + t[3]
    return ms