0

I am trying to convert the following string '1.12.22 14:16UTC+01:00' in Pandas to December 1st 2022

my_date = '1.12.22 14:16UTC+01:00'
new_date = pd.to_datetime(my_date)

Timestamp('2022-01-12 14:16:00-0100', tz='pytz.FixedOffset(-60)')

It inverts month with day only in specific cases. I am trying to use format="%d.%m.%Y %H:%M%z" but it says that the string is not matching the format.

time data '1.12.22 14:16UTC+01:00' does not match format '%d.%m.%Y %H:%M%z' (match)

Thanks for your help.

1

2 Answers 2

2
>>> pd.to_datetime('01.12.22 14:16UTC', format='%d.%m.%y %H:%M%Z')
Timestamp('2022-12-01 14:16:00+0000', tz='UTC')

I am not sure if this is what you are looking for, but your placeholders are wrong, check this page to know what they stand for.

Sign up to request clarification or add additional context in comments.

Comments

1

have you tried adding a zero?

my_date = '01.12.22 14:16UTC+01:00'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.