Issue
For example, I have a time in this format:
eg.
09:15 AM
04:25 PM
11:25 AM
How do I convert it to :
09:15
16:25
23:25
Currently my code is :
$format_time = str_replace(" AM", "", $time, $count);
if ($count === 0){
$format_time = strstr($time, ' PM', true);
$format_time = ......
}
However, it seems there are some easier and more elegant way to do this?
$time = '23:45';
echo date('g:i a', strtotime($time));
How do I fit the above sample in my case? Thanks.
Solution
Try with this
echo date("G:i", strtotime($time));
or you can try like this also
echo date("H:i", strtotime("04:25 PM"));
Answered By - Gautam3164 Answer Checked By - Terry (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.