I am using the following script to generate hours dynamically between a Start Value and a Final Value with a time interval.
For example: From 8:00 am to 3:30 p.m., with a 15 minute interval between times.
Code:
<?php
$start = '08:00';
$end = '15:30';
$st = explode(':', $start);
$ed = explode(':', $end);
for($hour = $st[0]; $hour <= $ed[0]; $hour++)
{
for($min = $st[1]; $min < 60; $min += 15)
{
if($ed[1] >= $min and $hour <= $ed[0])
echo "Hour: {$hour}:{$min}<br/>";
}
}
But if I put 15:00 as final value, the code does not generate the hours with minutes, only the complete hours. I need it to generate the minutes even when it is a full hour set to Final Value, such as 15:00.
NOTE: The script must be com for similar to the example, any other solution that follows a different structure I can not use in my final code.