I am trying to convert '2015-09-15T17:13:29.380Z'
to milliseconds.
At first I used:
time.mktime(
datetime.datetime.strptime(
"2015-09-15T17:13:29.380Z",
"%Y-%m-%dT%H:%M:%S.%fZ"
).timetuple()
)
I got 1442330009.0
- with no microseconds. I think time.mktime
rounds the number to the nearest second.
In the end I did:
origTime = '2015-09-15T17:13:29.380Z'
tupleTime = datetime.datetime.strptime(origTime, "%Y-%m-%dT%H:%M:%S.%fZ")
microsecond = tupleTime.microsecond
updated = float(time.mktime(tupleTime.timetuple())) + (microsecond * 0.000001)
Is there a better way to do this and how do I work with the timezone?