note 48130 added to ref.calendar

From: Date: Mon, 13 Dec 2004 11:36:38 +0000
Subject: note 48130 added to ref.calendar
Groups: php.notes 
Request: Send a blank email to php-notes+get-81742@lists.php.net to get a copy of this message
This is a function to make a calendar since 1980 without limit. You must pass the month and the year, and the function will return an array. With this array you can fill a table to make the calendar. The table will have got seven columns (obviously) and six rows. The first array's element must be placed in the upper cell of the first row. The second element must be placed in the upper cell of the second row, etc... Raúl ===#= //********************************************** function calendario($mes, $año){ if(((($mes%2)!=0)&&($mes<=7))||((($mes%2)==0)&&($mes>7))){ $NumDiasMes="31"; }else{ if($mes=="2"){ if(($año%4)=="0"){ $NumDiasMes="29"; }else{ $NumDiasMes="28"; } }else{ $NumDiasMes="30"; } } $añocero=array(2,5,5,1,3,6,1,4,7,2,5,7); $incremento=$año-1980; for ($i=1980;$i<($año);$i++){ if(($i%4)==0){ $incremento++; } } if(($año%4==0)&&($mes>2)) $incremento++; while($incremento>7) $incremento=$incremento-7; $DiaSemanaInicio=($añocero[abs($mes)-1]+$incremento); while($DiaSemanaInicio>7) $DiaSemanaInicio=$DiaSemanaInicio-7; if ($DiaSemanaInicio==0) $DiaSemanaInicio=7; for($i=0;$i<$NumDiasMes;$i++){ $aux=$i+$DiaSemanaInicio-1; $celda[$aux]=$i+1; } return $celda; } ---- Manual Page -- http://www.php.net/manual/en/ref.calendar.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48130 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48130&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48130&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48130&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48130&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48130&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48130&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48130&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81742) next »