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

PHP日历代码通用函数

WBOY
Freigeben: 2016-06-21 08:57:26
Original
1100 Leute haben es durchsucht
<?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>



Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage