A function that made by idate for print a hour you want:
<?php
function hour ( $a, $b )
{
$timestamp = strtotime(''.$a.':'.$b.':00');
$aa = idate('H', $timestamp);
$bb = idate('i', $timestamp);
if($bb=="0") { $cc = "00"; } else { $cc = $bb; }
$dd = $aa.".".$cc;
return($dd);
}
?>
Why should i use it?
For example:
You have to print 08:00 to 21:00 by 15 minutes periods.
This is a useful code for shipping sites for delivery time.
<?php
echo "<select name=\"example\">";
for($i=8;$i<=20;$i++)
{
for($ii=0;$ii<=3;$ii++)
{
$iii = $ii * 15;
$hour = hour($i, $iii);
echo "<option value=\"".$hour."\">".$hour."</option>";
}
}
echo "</select>";
?>