
Untitled
By: a guest on
Jun 17th, 2012 | syntax:
None | size: 0.44 KB | hits: 19 | expires: Never
python convert date and time into linux timestmap
2011 February 2nd 13h 27min 21s
110202 132721
>>> s = "110202 132721"
>>> print time.mktime(time.strptime(s, "%y%m%d %H%M%S"))
1296653241.0
from datetime import datetime
import pytz
import calendar
a = "110202 132721"
yourTZ = 'America/Los_Angeles'
calendar.timegm(pytz.timezone(yourTZ).localize(datetime.strptime(a, '%y%m%d %H%M%S')).utctimetuple())
# returns 1296682041