Another way to have time in the era is to use mktime from a time module and pass in a temporary date tuple so you can do this:
>>> from datetime import datetime >>> from time import mktime >>> dt = datetime.strptime("02:31:33 PM", "%H:%M:%S %p") >>> dt_now = datetime.now() >>> dt = dt.replace(year=dt_now.year, month=dt_now.month, day=dt_now.day) >>> int(mktime(dt.timetuple())) 1377131493
source share