note 9582 added to Date and Time functions

From: Date: Mon, 13 Nov 2000 17:13:00 +0000
Subject: note 9582 added to Date and Time functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-7639@lists.php.net to get a copy of this message
I was trying to make a Month-At-A-Glance and I finally got it to work so I thought I'd share it too. What you need to get this to work is the "Day Of The Week Number", i.e., Sunday=1 and the "Number Of Days in the Month". I also used Allan Kent's Date/Time Column at PHPBuilder to get the required information. I also added the process I used to the requried information. Enjoy! <pre> <html> <head> <title>Month-At-A-Glance</title> </head> <body> <?php // *** These are here if you need to calculate the required values *** // *** Reference Allan Kent's Column on Dates at PHPBuilder.com //$thismonth = mktime($hours, $minutes,$seconds ,$month, $day,$year); //$firstday = mktime($hours, $minutes,$seconds ,$month, 1,$year); //$dayofweek=date("D",$thismonth); //$firstdayofmonth=date("D",$firstday); //$weekdaynum=array("Sun"=>1,"Mon"=>2,"Tue"=>3,"Wed"=>4,"Thu"=>5,"Fri"=>6,"Sat"=>7); //$dayNumber=$weekdaynum[$dayofweek]; print "<table width=80% align=center border=1>\n"; print"<tr><th>Sun(1)</th><th>Mon(2)</th><th>Tue(3)</th><th>Wed(4)</th><th>Thu(5)</th><th>Fri(6)</th><th>Sat(7)</th></tr>"; $daysinmonth=31;//For July 2000 this is 31 days $daycount=1; $firstdayofmonth=7;//For July 2000 this is Sat, or day 7 for ($week=1; $week <= 6; $week++){ print"<tr>\n"; for($day=1; $day <=7; $day++){ if( ($day >= $firstdayofmonth) || ($week >1) ){ print"<td height=40px>"; if ($daycount <= $daysinmonth){ print $daycount; $daycount++; } print"&nbsp;</td>\n"; } else{ print"<td height=40px> &nbsp; </td>\n"; } } print"\n</tr>\n"; } print"</table>"; ?> </body> </html> </pre> http://www.php.net/manual/ref.datetime.php

« previous php.notes (#7639) next »