Posted By

jimmayes on 02/26/08


Tagged

mysql time format conversion hour 24 12 military


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

basicmagic
todds
adix
DADU


simple 24 hour time (MySQL or military) to 12 hour time conversion


 / Published in: PHP
 

URL: http://style-vs-substance.com/convert-24-hour-military-time-to-12-hour-ampm-time-in-php/2007/10/

simple and clean... convert 24 hour format to 12 hour format with PHP native functions.

BTW, works in the other direction too (12 hour to 24 hour)... that's the second line below

  1. <?=date("g:i a", strtotime("13:30"));?>
  2.  
  3.  
  4. <?=date("H:i", strtotime("1:30 pm"));?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: axthos on May 22, 2008

I had totally forgotten about using g:i a instead of H:i... thanks for this.

You need to login to post a comment.