note 31662 added to function.date
| From: | augusto at dcc dot ufmg dot br | Date: | Tue, 29 Apr 2003 18:07:25 +0000 |
| Subject: | note 31662 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47251@lists.php.net to get a copy of this message | ||
a code to generate a calendar...
<?
$next_year = $prev_year = date(Y) ;
switch ($month)
{
case 0:
$month = date(m) ;
$next_month = $mounth + 1;
$prev_month = $mounth - 1;
break;
case 1:
$prev_month = 12;
$prev_year--;
break;
case 12:
$next_month = 1;
$next_year++ ;
break;
}
print "mes: $month, ano $year<br>";
?>
<table border = 1>
<tr>
<td>d</td>
<td>s</td>
<td>t</td>
<td>q</td>
<td>q</td>
<td>s</td>
<td>s</td>
</tr>
<tr>
<?
$n_days_of_month = date("t", mktime(0,0,0, $mounth, date(d),date(Y)));
for ($day = 0 ; $day < date("w", mktime(0,0,0, $month, 1 ,date(Y))) ; $day ++)
/*looking for Sunday*/
{
print "\t\t<td> </td>\n";
}
for ( $day = 1 ; $day <= $n_days_of_month ; $day ++)
{
$day_of_month = date("d", mktime(0,0,0, $mounth , $day ,date(Y)));
$day_of_week = date("w", mktime(0,0,0, $month , $day ,date(Y)));
print "\t\t<td> $day_of_month </td>\n";
if ($day_of_week == 6)
/*end of the week*/
{
print "\t</tr>\n";
print "\t<tr>\n";
}
}
?>
</tr>
</table>
<?
printf ("<a href =
\"index.php?month=%d&year=%d\"><<</a>",$prev_mounth,$prev_year);
printf ("<a href =
\"index.php?month=%d&year=%d\">>></a>",$next_mounth,$next_year);
?>
--
http://www.php.net/manual/en/function.date.php
http://master.php.net/manage/user-notes.php?action=edit+31662
http://master.php.net/manage/user-notes.php?action=delete+31662
http://master.php.net/manage/user-notes.php?action=reject+31662