Click to See Complete Forum and Search --> : Loop through hours in day


mattastic
06-05-2006, 03:41 AM
Hi,

Can anyone tell me how to do this?

I want to loop thourhg the hours 9-00 to 5-00

So far I have this but it diesnt work.

Thankyou



for ($i = mktime(9, 0, 0, 0, 0, 0); $i <= mktime(17, 0, 0, 0, 0, 0); $i++)
{
echo $i;

}

GaryS
06-05-2006, 03:53 AM
Is this what you're trying to achieve:


for ($i = 9; $i < 18; $i++){

echo '<p>' . mktime($i, 0, 0, 0, 0, 2006);


}

mattastic
06-05-2006, 10:05 AM
Thankyou, do you know how I can loop through the time wihout repeating the date on the hour:



for ($i = 9; $i < 17; $i++)
{
for ($s = 0; $s <= 60; $s+=15)
{

echo " <td>" . date('G:i:s', mktime($i, $s, 0, 0, 0, 2006)) . "</br>\n";
}
}

GaryS
06-05-2006, 10:09 AM
Change your <= to < Think that will do it.