Home >> Snippet List >> Snippet

Convert 12 to 24 hour time and vice versa
Convert 24-hour format to 12-hour format Also works in the other direction too (12 hour to 24 hour)
PHP Snippet
// 24-hour time to 12-hour time 
$time_in_12_hour_format  = DATE("g:i a", STRTOTIME("13:30"));
// 12-hour time to 24-hour time 
$time_in_24_hour_format  = DATE("H:i", STRTOTIME("1:30 pm"));