I have created a php function to return time in digital clock format. My function is
function get_hh_mm_ii($unsorted_time) {
//return $unsorted_time;
if ($unsorted_time == '00:00') {
return 'x';
} elseif ($unsorted_time != '00:00') {
$time = explode(":", $unsorted_time);
$hh = $time[0];
$mm = $time[1];
//var_dump($hh/12); exit();
if (($hh / 12) == 0) {
$ii = 'am';
return $hh . ':' . $mm . ' ' . $ii;
} elseif (($hh / 12) == 1) {
$ii = 'pm';
$hh = $hh % 12;
if ($hh == 0) {
$hh == 12;
}
return $hh . ':' . $mm . ' ' . $ii;
}
}
}
When I tried to pass value (02:03) or any other it always returns NULL. I checked its value using var_dump.
Try this one:
The problem is that 13 and anything else, except 12 divided by 12 is not one.