Karn_way
Karn_way

Reputation: 1015

time.mktime(datetime.timetuple()) seems behaving incorrectly

Hi I have time converted into gmt as below 2016-11-18 13:00:00+00:00 I want to convert this into millis which I am doing as below

epoch = int(time.mktime(datetime_in_gmt.timetuple()))

>>>print(epoch)
1479454200

and then when I do use this link http://www.epochconverter.com/ and paste this epoch i.e 1479454200 I get the result as

GMT: Fri, 18 Nov 2016 07:30:00 GMT Your time zone: Friday 18 November 2016 01:00:00 PM IST GMT+5:30

I am not getting as why I am getting 18 Nov 7.30 as GMT because my GMT time was 2016-11-18 13:00:00+00:00 ? any suggestion

Upvotes: 1

Views: 764

Answers (1)

Nirbhay Kumar
Nirbhay Kumar

Reputation: 72

Instead of timetuple use timestamp. Something like int(datetime_in_gmt.timestamp()) * 1000

Upvotes: 1

Related Questions