Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert army time to regular time AM PM in PHP [closed]

Tags:

php

time

I'm looking for a way to convert army time (such as 23:00) to regular time with the AM/PM expression.

like image 865
tbradley22 Avatar asked Jun 10 '13 22:06

tbradley22


2 Answers

Just pass your time in strtotime function like this:

$time_in_12_hour_format = date("g:i a", strtotime("23:00"));
echo $time_in_12_hour_format;
like image 182
sharif2008 Avatar answered Oct 05 '22 04:10

sharif2008


http://www.php.net/manual/en/function.date.php

$army_time_str = "23:00";
$regular_time_str = date( 'g:i A', strtotime( $army_time_str ) );
echo $regular_time_str;
like image 30
Scott Mutch Avatar answered Oct 05 '22 04:10

Scott Mutch