Re: dynamical dates
| From: | Matt | Date: | Sun, 03 Dec 2000 17:33:27 +0000 |
| Subject: | Re: dynamical dates | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28450@lists.php.net to get a copy of this message | ||
$thetime=mktime(8,0,0,4,3,1980); // this sets the orignial time, the date
is irrelavant, but the first three numbers
// coorespond to the
hour, minute, second.
for ($c=0;$c<$iterations;$c++) { // iterations is the number of times
you want to go through the loop
echo date("g:i a",$thetime); // look at the date function, this
returns the hour:minute am/pm of the $thetime timestamp
$thetime += (60*30); // add 30 minutes to the current time
}
----- Original Message -----
From: "Siim Einfeldt aka Itpunk" <siim_e@pshg.edu.ee>
Cc: <php-general@lists.php.net>; <php_mysql@egroups.com>;
<php_uk@egroups.com>
Sent: Sunday, December 03, 2000 5:50 AM
Subject: [PHP] dynamical dates
>
> 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
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>