Time
Peter Hansen
peter at engcorp.com
Wed Apr 21 15:26:16 EDT 2004
Jonas Galvez wrote:
> If I have a tuple like this:
>
> (year, month, day, hour, minute)
>
> Is there a way to automatically generate a string like this?
>
> "YYYY-MM-DDTHH:MM:00"
>
> I remember seeing something about it somewhere... wanted to be sure.
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.
-Peter
More information about the Python-list
mailing list