Maison > php教程 > php手册 > PHP日历代码通用函数

PHP日历代码通用函数

WBOY
Libérer: 2016-06-21 08:57:26
original
1101 Les gens l'ont consulté
<?php <br/>//calendar.php<br>//Check if the month and year values exist<br>if ((!$_GET['month']) && (!$_GET['year'])) {<br>   $month = date ("n");<br>   $year = date ("Y");<br>} else {<br>   $month = $_GET['month'];<br>   $year = $_GET['year'];<br>}<br>//Calculate the viewed month<br>$timestamp = mktime (0, 0, 0, $month, 1, $year);<br>$monthname = date("F", $timestamp);<br>//Now let's create the table with the proper month<br>?><br><table style="width: 105px; border-collapse: collapse;" border="1" cellpadding="3" cellspacing="0" bordercolor="#000000"> <br>   <tr> <br>   <td colspan="7" class="calendartodayoff"> <br>    <span style="font-weight: bold;"><?php echo &#36;monthname . " " . &#36;year; ?></span><br>   </td> <br>   </tr> <br>   <tr> <br>   <td class="calendartodayoff"> <br>    <span style="font-weight: bold;">Su</span><br>   </td> <br>   <td class="calendartodayoff"> <br>    <span style="font-weight: bold;">M</span><br>   </td> <br>   <td class="calendartodayoff"> <br>    <span style="font-weight: bold;">Tu</span><br>   </td> <br>   <td class="calendartodayoff"> <br>    <span style="font-weight: bold;">W</span><br>   </td> <br>   <td class="calendartodayoff"> <br>    <span style="font-weight: bold;">Th</span><br>   </td> <br>   <td class="calendartodayoff"> <br>    <span style="font-weight: bold;">F</span><br>   </td> <br>   <td class="calendartodayoff"> <br>    <span style="font-weight: bold;">Sa</span><br>   </td> <br>   </tr> <br>   <?php <br/>    $monthstart = date("w", $timestamp);<br>    $lastday = date("d", mktime (0, 0, 0, $month + 1, 0, $year));<br>    $startdate = -$monthstart;<br>   <br>    //Figure out how many rows we need.<br>    $numrows = ceil (((date("t",mktime (0, 0, 0, $month + 1, 0, $year)) + $monthstart) / 7));<br>   <br>    //Let's make an appropriate number of rows...<br>    for ($k = 1; $k      ?><tr> <?php <br/>     //Use 7 columns (for 7 days)...<br>     for ($i = 0; $i       $startdate++;<br>      if (($startdate $lastday)){<br>       //If we have a blank day in the calendar.<br>       ?><td style="background: #FFFFFF;"> </td> <?php <br/>      } else {<br>                <br>       if ($startdate == date("j") && $month == date("n") && $year == date("Y")){<br>        ?><td class="calendartodayoff" .>',event);" ><?php echo date ("j"); ?> </td> <?php <br/>       } else {<br>        ?><td class="calendaroff" .>',event);" ><?php echo &#36;startdate; ?> </td> <?php <br/>       }<br>      }<br>     }<br>     ?></tr> <?php <br/>    }<br>   ?>    <br> </table>



Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal