Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.44 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. python convert date and time into linux timestmap
  2. 2011 February 2nd  13h 27min 21s
  3. 110202             132721
  4.        
  5. >>> s =  "110202 132721"
  6. >>> print time.mktime(time.strptime(s, "%y%m%d %H%M%S"))
  7. 1296653241.0
  8.        
  9. from datetime import datetime
  10. import pytz
  11. import calendar
  12.  
  13. a = "110202 132721"
  14. yourTZ = 'America/Los_Angeles'
  15.  
  16. calendar.timegm(pytz.timezone(yourTZ).localize(datetime.strptime(a, '%y%m%d %H%M%S')).utctimetuple())
  17.  
  18. # returns 1296682041