[Tutor] Python time hour formatting
Eric Culpepper
eculpepper at hcc-care.com
Thu Mar 25 17:23:49 EST 2004
Check the http://www.python.org/doc/current/lib/module-time.html document for the time module for all the different options for strftime.. but to directly answer your question you can use %H for 24 hour format, %I is for 12 hour format.
-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org]On
Behalf Of tpc at csua.berkeley.edu
Sent: Thursday, March 25, 2004 4:15 PM
To: tutor at python.org
Subject: [Tutor] Python time hour formatting
hi everyone, quick question. I currently have this:
time.strftime("%a %b %d, %Y %I:%M:%S %p",time.localtime(time.time()))
to print out:
'Thu Mar 25, 2004 02:19:23 PM'
However, I don't want a leading zero in the hour column if
there is only one digit. Is there a way to do this:
'Thu Mar 25, 2004 2:19:23 PM'
?
I already tried '%1I' to no avail.
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list