Guest User

Untitled

a guest
Apr 26th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. def ISO8601ToEpoch(theString):
  2.  
  3. from datetime import datetime
  4. import calendar
  5.  
  6. return calendar.timegm(datetime.strptime(theString, "%Y-%m-%dT%H:%M:%S.%f").timetuple())
  7.  
  8. def EpochToISO8601(theEpoch):
  9.  
  10. from datetime import datetime
  11.  
  12. return datetime.fromtimestamp(theEpoch).isoformat()
  13.  
  14. #
  15.  
  16. print 'Original Time {0}'.format('2018-04-27T04:19:51.050937')
  17.  
  18. theTime=ISO8601ToEpoch('2018-04-27T04:19:51.050937')
  19. print 'Time {0}'.format(theTime)
  20.  
  21. print 'Original Time {0}'.format(EpochToISO8601(theTime)
Add Comment
Please, Sign In to add comment