Saturday, August 15, 2009

A simple code to handle Time



$time="08:05:00"; //for sake of example .initial time
$curtime="01:05:00";//end time

$t=explode(':',$time);
$h=intval($t[0]);
$m=intval($t[1]);

$add=1;

while($ntime!=$curtime)
{
$h=intval($h);
$m=intval($m);
$m+=$add;

if($m>=60)
{
$h++;
$m=$m-60;
}
if($h>23)
$h=0;

if($h<10)
{
$h="0".$h;
}
if($m<10)
{
$m="0".$m;
}

$ntime=$h.":".$m.":00";
echo $ntime."
"; //it will echo each minute
}

No comments:

Post a Comment