This date format 2018-11-11 01:54:16+00:00
should be converted to Nov 11, 2018 7:24:16 AM GMT+0530
Input : 2018-11-11 01:54:16+00:00
Expected : Nov 11, 2018 7:24:16 AM GMT+0530
Actual : Nov 11, 2018 07:24:16 AM IST+0530
I'm able to convert the time but not Time-zone as specified above Expected
& Actual
(GMT
& IST
) . Below snippet details :
from pytz import timezone
from dateutil import parser
from datetime import datetime
fmt = "%b %d, %Y %H:%M:%S %p %Z%z"
dt = '2018-11-11 01:54:16+00:00'
tmp = parser.parse(dt)
t1 = tmp.astimezone(timezone('Asia/Kolkata'))
print t1 #prints "2018-11-11 07:24:16+05:30"
print t1.strftime(fmt) #prints "Nov 11, 2018 07:24:16 AM IST+0530"
t1 = tmp.astimezone(timezone('GMT'))
print t1.strftime(fmt) #prints "Nov 11, 2018 01:54:16 AM GMT+0000"
Am I missing something to print GMT
(instead of IST
) ?
Nov 11, 2018 7:24:16 AM GMT+0530