import pendulum dt = pendulum.parse('2022-05-21T22:00:00') print(dt)
#we can pass tz keyboard to speciafy the timezone dt = pendulum.parse('2022-05-21T22:00:00', tz='Europe/Paris') print(dt) dt = pendulum.parse('2022-05-21 22:00:00')
2022-05-21T22:00:00+00:00 2022-05-21T22:00:00+02:00
If you pass a non-standard or more complicated string, it will raise an exception, so it is advised to use the from_formate() helper insted
However, if you want the library to fall back on the dateutil parser, you have to pass strict=False
.
#Code
import pendulum
dt = pendulum.parse('31-01-01', strict=False)
print(dt)
#OUTPUT2031-01-01T00:00:00+00:00
Comments