I am getting hairless about this topic since some hours now...
As inputs, I have timestamps stored as strings in a list:
0 Sat Mar 30 2019 21:00:00 GMT+0100
1 Sat Mar 30 2019 22:00:00 GMT+0100
2 Sat Mar 30 2019 23:00:00 GMT+0100
When I convert them into datetime object, timezone is reversed:
GC['date'] = pd.to_datetime(my_timestamps)
0 2019-03-30 21:00:00-01:00
1 2019-03-30 22:00:00-01:00
2 2019-03-30 23:00:00-01:00
I have double checked what GMT+1 means on Google.
Considering a UTC time 9 o'clock, GMT+1 time is then 10 o'clock: it is 1 hour more than UTC.
So to get UTC, you should offset GMT+1 time by -1 hour.
I was thus ok with having -1 in the offset then:
0 2019-03-30 21:00:00-01:00
And now, when I try to 'resolve' the offset, I get:
GC['date2'] = pd.to_datetime(my_timestamps, utc=True)
0 2019-03-30 22:00:00+00:00
1 2019-03-30 23:00:00+00:00
2 2019-03-31 00:00:00+00:00
OMG, the offset is reversed. Ok, let's double check with Google again:
https://pythontic.com/datetime/datetime/utcoffset
Output of the code is a +8 hours offset for Singapore vs UTC
Singapore Time instance:2017-02-14 12:15:01.000099+08:00
UTC Offset for Singapore Time:8:00:00
And from Singapore time, to find UTC time, you have to substract these 8 hours:
Singapore time: 5 hour AM
UTC time: 21 hour PM
So the trouble appears to be during the conversion step GMT+1 -> -01:00 in to_datetime.
Please, does anyone has an idea on how solving that? I thank you in advance for your help.
Bests,
Pierre