Simplest solution for formatting local time in iso 8601 including time zone.

Chris Rebert clp at rebertia.com
Wed Sep 10 00:40:57 EDT 2008


On Tue, Sep 9, 2008 at 9:32 PM,  <rowland at river2sea.org> wrote:
> What's the simplest solution for formatting the output of local time
> in iso 8601 including the time zone information?
>
> Example:
>
>    "2008-07-25T14:28:43.934-04:00"

You want the isoformat() method of datetime objects.
See http://docs.python.org/lib/datetime-datetime.html for details.

You'll need to pass 'T' as the separator to isoformat() and pass in a
tzinfo object when constructing the datetime object.

Regards,
Chris

>
>
> Thanks,
> Rowland
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list