PDA

View Full Version : Need help to convert 24 hr time to 12 hr time


jmhitz
10-28-2008, 05:45 AM
I need to write a program that converts 24 hour time to 12 hour time.
And I need three functions (an input function, conversion function, and output function).
Can someone show me some example code so I can get this to work.
Thank you so much for any and ALL help :thumbsup:

hthought
05-02-2009, 03:24 AM
That should do it :



>>> from time import gmtime, strftime
>>> strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
'Thu, 28 Jun 2001 14:17:15 +0000'




check here for strftime codes:

http://docs.python.org/library/time.html#time.strftime