Converting utc time string to datetime object

The parser from dateutil is your friend.

You’ll have to pip install dateutil but you’ve save bags and bags of date conversion code:

pip install python-dateutil

You can use it like this.

from dateutil import parser
ds="2012-03-01T10:00:00Z" # or any date sting of differing formats.
date = parser.parse(ds)

You’ll find you can deal with almost any date string formats with this parser and you’ll get a nice standard python date back

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)