note 9582 modified in ref.datetime by irchtml
| From: | irchtml@php.net | Date: | Wed, 25 Feb 2004 14:14:27 +0000 |
| Subject: | note 9582 modified in ref.datetime by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65717@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!
<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" </td>\n";
}
else{
print"<td height=40px> </td>\n";
}
}
print"\n</tr>\n";
}
print"</table>";
?>
</body>
</html>
--was--
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!
<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" </td>\n";
}
else{
print"<td height=40px> </td>\n";
}
}
print"\n</tr>\n";
}
print"</table>";
?>
</body>
</html>
http://www.php.net/manual/en/ref.datetime.php