Back
I have a Python datetime an object that I want to convert to UNIX time, or seconds/milliseconds since the 1970 epoch.
datetime
How do I do this?
You can use this:
import datetimeepoch = datetime.datetime.utcfromtimestamp(0)def unix_time_millis(dt): return (dt - epoch).total_seconds() * 1000.0
import datetime
epoch = datetime.datetime.utcfromtimestamp(0)
def unix_time_millis(dt):
return (dt - epoch).total_seconds() * 1000.0
31k questions
32.8k answers
501 comments
693 users