How to convert a python utc datetime to a local datetime using only python standard library?

Posted by Nitro Zark on Stack Overflow See other posts from Stack Overflow or by Nitro Zark
Published on 2010-12-30T14:14:41Z Indexed on 2010/12/30 14:53 UTC
Read the original article Hit count: 417

I have a python datetime instance that was created using datetime.utcnow() and persisted in database.

For display, I would like to convert the datetime instance reloaded from database to local datetime using the default local timezone (e.g. as if the datetime was create using datetime.now())

How can I convert the utc datetime to a local datetime using only python standard library (e.g. no pytz dependency)?

It seems one solution would be to use datetime.astimezone( tz ), but how would do you get the default local timezone?

© Stack Overflow or respective owner

Related posts about python

Related posts about datetime