Skip to content Skip to sidebar Skip to footer

In Python 2.5, How To Print Current Timestamp In Full ISO 8601 Format

I'm sure this must be answered somewhere, but I can't find it. How do I print the current local date/time in ISO 8601 format, including the local timezone info? eg: 2007-04-05T12:3

Solution 1:

Usually this is done via isoformat. It should be available in Python 2.5.

from datetime import datetime
dt = datetime.now()
dt.isoformat("T")

which yields:

'2014-07-03T17:36:23.622683'

If you have correct UTC offsets in your tzinfo this should be rendered aswell.


Post a Comment for "In Python 2.5, How To Print Current Timestamp In Full ISO 8601 Format"