Your code will behave strange if 'TZ' is not set properly, eg 'UTC' or 'Asia/Kolkata' So, you need to do below >>> import time, os >>> d='2014-12-11 00:00:00' >>> p='%Y-%m-%d %H:%M:%S' >>> epoch = int(time.mktime(time.strptime(d,p))) >>> epoch 1418236200 >>> os.environ['TZ']='UTC' >>> epoch = int(time.mktime(time.strptime(d,p))) >>> epoch 1418256000
Mohammad Shahid Siddiqui Jan 6 '15 at 9:06 2015-01-06 09:06
source share