How to convert military time to standard time?

Discussion in 'PHP' started by greatlogix, Dec 30, 2010.

  1. #1
    MySQL saves time in military format in datetime field. I want to show this as standard time on the page. How can I do it?
    I want to convert 23:55:12 to 11:55:12 PM
     
    greatlogix, Dec 30, 2010 IP
  2. Cida

    Cida Peon

    Messages:
    6
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can convert it to a time stamp with strtotime(), and then format it with date().
    
    $military_time = '23:55:12';
    $standard_time = date('h:i:s A', strtotime($military_time));
    
    Code (php):
     
    Cida, Dec 30, 2010 IP