mardi 14 juin 2016

Python : Converting time string with different timezone to host timezone datetime object?


My host has timezone UTC and I am trying to convert PDT time string to date time object, I have used the below given code-snippet but it didn't worked

datetime_obj = datetime.datetime.strptime('Thu Jun 09 08:28:12 PDT 2016', '%a %b %d %H:%M:%S %Z %Y')

I am getting this error -

ValueError: time data 'Thu Jun 09 08:28:12 PDT 2016' does not match format '%a %b %d %H:%M:%S %Z %Y'

I got it that it's because my host's timezone is UTC. But I am not able to figure out the way to solve this issue. I need to convert PDT string to UTC aware timezone.

I am blocked. Any help Appreciated.


Aucun commentaire:

Enregistrer un commentaire