Quantcast
Channel: How to get current isoformat datetime string including the default timezone? - Stack Overflow
Viewing all articles
Browse latest Browse all 7

How to get current isoformat datetime string including the default timezone?

$
0
0

I need to produce a time string that matches the iso format yyyy-mm-ddThh:mm:ss.ssssss-ZO:NE. The now() and utcnow() class methods almost do what I want.

>>> import datetime>>> #time adjusted for current timezone>>> datetime.datetime.now().isoformat()'2010-08-03T03:00:00.000000'>>> #unadjusted UTC time>>> datetime.datetime.utcnow().isoformat()'2010-08-03T10:00:00.000000'>>>>>> #How can I do this?>>> datetime.datetime.magic()'2010-08-03T10:00:00.000000-07:00'

Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles



Latest Images