- time: documentation ( source)
<?php
$seconds_in_hour = 60 * 60;
$seconds_in_day = $seconds_in_hour * 24;
$epoch = time();
$current_hour = $epoch % $seconds_in_day / $seconds_in_hour;
echo $current_hour;
if ($current_hour > 12) {
$time_prefix = "pm";
$current_hour -= 12;
} else {
$time_prefix = "am";
}
echo $current_hour;
echo $time_prefix;
?>