I have data frame which has a column full of date-time of format yyyy-mm-ddTHH:MM:SSS.000Z
For example, 2019-06-17T19:17:45.000Z. I want to convert this to long type (unix epoch time) in python.
How to do that?
Thanks!
(How do I parse an ISO 8601-formatted date? This question is abut parsing the string. I want to do a conversion and hence it is different)
解决方案
Use module time:
import calendar
import time
calendar.timegm(time.strptime('2019-06-17T19:17:45.000Z', '%Y-%m-%dT%H:%M:%S.%fZ'))
Output: 1560799065