Time
Jonas Galvez
jonas at jonasgalvez.com
Wed Apr 21 15:40:56 EDT 2004
Thanks all.
> [Mike Fletcher]
> That format is the ISO standard date-time format. The modern way
> to work with date-times in Python is to use the datetime module,
> so:
>
> >>> import datetime
> >>> d = datetime.datetime( 2004, 4, 21, 15, 05)
> >>> d.isoformat()
> '2004-04-21T15:05:00'
>
> You can use datetime.datetime( * mytuple ) to auto-unpack your
> tuple, btw.
Cool, that's what I was looking for.
> [Peter Hansen]
> You want to read about the "time" module:
>
> >>> t = (2004, 4, 21, 15, 33)
> >>> import time
> >>> time.strftime('%Y-%m-%dT%H:%M:00', t+(0,0,0,0))
> '2004-04-21T15:33:00'
>
> I left the "T" in there as a literal because I don't know what you
> meant it to be and there's no obvious single-character
> substitution.
The "T" is from the W3C format:
http://www.w3.org/TR/NOTE-datetime
I need it to generate valid RSS/ATOM feeds.
=-
Jonas Galvez
jonasgalvez.com/blog
macromedia.com/go/team
More information about the Python-list
mailing list