Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question Need help to convert 24 hr time to 12 hr time

    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

  • #2
    New Coder
    Join Date
    May 2009
    Posts
    55
    Thanks
    1
    Thanked 4 Times in 4 Posts
    That should do it :

    Code:
     
    
    >>> 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
    Last edited by hthought; 05-02-2009 at 03:28 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •