dynamical dates
| From: | Siim Einfeldt aka Itpunk | Date: | Sun, 03 Dec 2000 10:50:53 +0000 |
| Subject: | dynamical dates | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28425@lists.php.net to get a copy of this message | ||
I have a list of times...8:00,8:30,9:00....and so on until 01.30am. How
could I get them dynamically without the need to write all the times
out? with some for loop in php probably, but it seems to be a little more
than that as the time doesn`t go to 24, but to 1 etc.
actually I have written the following code for that, but I`m sure it can
be written in a shorter way. So I`ll be waiting for your suggestions.
My code:
<?php
echo "<TABLE border=0>";
for($ie=8;$ie<=24;$ie++){
if(!isset($st) or $st == 30){
$st = "00";
}else{
$st = 30;
}
if($f != $ie AND $ie!= 8){
$f = $ie;
$ie -= 1;
$kt=$ie;
}
if($ie==24){
$kt= "00";
$ie=$kt;
echo "<TR><TD>$ie:$st</TD></TR>";
break;
}
echo "<TR><TD>$ie:$st</TD></TR>";
}
for($ie="00";$ie<=2;$ie++){
if(!isset($st2) or $st2 == 00){
$st2 = "30";
}else{
$st2="00";
}
if($f != $ie AND $ie > 1){
$f = $ie;
$ie -= 1;
$kt = $ie;
}
if($ie==2){
break;
}
echo "<TR><TD>$ie:$st2</TD></TR>";
}
echo "</TABLE>";
?>
Cheers
Siim