0

So here I am trying to figure out how to convert a matching format.

What I have done right now is that I have following code:

xmas_time = '2018-12-24T00:00:00+01:00'
utc_date = datetime.strptime(xmas_time, "%Y-%m-%dT%H:%M:%S%z").replace(tzinfo=timezone.utc)
etatime = utc_date.astimezone(pytz.timezone('Europe/Stockholm'))
merry_xmas = etatime.strftime('%Y-%m-%d %H:%M:%S')
print(merry_xmas)

however I am getting an issue saying:

ValueError: time data '2018-12-24T00:00:00+01:00' does not match format '%Y-%m-%dT%H:%M:%S%z'

which I believe I probably did the match format incorrect and here I am needing help how I will be able to solve that!

Output that I would wish is: yyyy-mm-dd hh-mm-ss

martineau
  • 119,623
  • 25
  • 170
  • 301
Hellosiroverthere
  • 285
  • 10
  • 19
  • Look [here](https://stackoverflow.com/questions/127803/how-do-i-parse-an-iso-8601-formatted-date-in-python) and [here](https://stackoverflow.com/questions/311627/how-to-print-a-date-in-a-regular-format). – Robert Harvey Dec 23 '18 at 16:30
  • I followed and many of them recommend to use `%Y-%m-%dT%H:%M:%S%z` which I also do use for this solutions. But I do get the same error strangely... @RobertHarvey – Hellosiroverthere Dec 23 '18 at 16:40

0 Answers0