Skip to content
Advertisement

Remove timezone (+01:00) from DateTime

I would like to delete the timezone from my dateTime object.
Currently i have:
2019-02-21 15:31:37+01:00

Expected output:
2019-02-21 15:31:37

The code I have converts it to: 2019-02-21 14:31:37.

JavaScript

Advertisement

Answer

In the first line, the parameter utc=True is not necessary as it converts the input to UTC (subtracting one hour in your case).

In the second line, I get an AttributeError: 'Timestamp' object has no attribute 'dt'. Be aware that to_datetime can return different objects depending on the input.

So the following works for me (using a Timestamp object):

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement