note 31662 deleted from function.date by philip

From: Date: Sat, 02 Aug 2003 15:32:23 +0000
Subject: note 31662 deleted from function.date by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-53209@lists.php.net to get a copy of this message
Note Submitter: augusto@dcc.ufmg.br ---- 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> &nbsp;</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); ?>

« previous php.notes (#53209) next »