note 7973 modified in ref.datetime by irc-html
| From: | irc-html@php.net | Date: | Sun, 20 Jan 2002 02:04:24 +0000 |
| Subject: | note 7973 modified in ref.datetime by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25548@lists.php.net to get a copy of this message | ||
This is a little procedure to make time loop under a start time, end time and an interval,I have
done the same type thing with the date.
where you see:
echo "Time: $timeh:$timem<br>\n";
that is my command you can of course call your own functions with the vars,$timeh & $timem.
$timeh = "9"; # Inital Start Time (hours part)
$timem = "30"; # Inital Start Time (mins part)
$end_timeh = "17"; # End Time (hours)
$end_timem = "30"; # End Time (mins)
$interval = "5"; # Interval (mins)
$exit_called = "0";
while ($exit_called == "0")
{
# Pad is a my pre-deffined function add a '0' infront of a var if need be for proper
formating.
$timem = pad($timem);
$timeh = pad($timeh);
# command goes here for execution with the time
echo "Time: $timeh:$timem<br>\n";
if($timeh >= $end_timeh)
{
$exit_called = "1";
}
else
{
# Increment Counters
$timem = $timem + $interval;
if($timem >= "60")
{
$answer = ($timem / 60);
$round_val = round($answer);
if($round_val > $answer)
{
$round_val = ($round_val - 1);
}
$timeh = ($timeh + $round_val);
$round_val = ($round_val * 60);
$timem = ($timem - $round_val);
}
}
}
--was--
This is a little procedure to make time loop under a start time, end time and an interval,I have
done the same type thing with the date.
where you see:
echo "Time: $timeh:$timem<br>\n";
that is my command you can of course call your own functions with the vars,$timeh & $timem.
$timeh = "9"; # Inital Start Time (hours part)
$timem = "30"; # Inital Start Time (mins part)
$end_timeh = "17"; # End Time (hours)
$end_timem = "30"; # End Time (mins)
$interval = "5"; # Interval (mins)
$exit_called = "0";
while ($exit_called == "0")
{
# Pad is a my pre-deffined function add a '0' infront of a var if need be for proper
formating.
$timem = pad($timem);
$timeh = pad($timeh);
# command goes here for execution with the time
echo "Time: $timeh:$timem<br>\n";
if($timeh >= $end_timeh)
{
$exit_called = "1";
}
else
{
# Increment Counters
$timem = $timem + $interval;
if($timem >= "60")
{
$answer = ($timem / 60);
$round_val = round($answer);
if($round_val > $answer)
{
$round_val = ($round_val - 1);
}
$timeh = ($timeh + $round_val);
$round_val = ($round_val * 60);
$timem = ($timem - $round_val);
}
}
}
http://www.php.net/manual/en/ref.datetime.php