PHP simple calendar implementation method, php calendar implementation

Source: Internet
Author: User

PHP simple calendar implementation method, php calendar implementation

This example describes how to implement a simple PHP calendar. We will share this with you for your reference. The details are as follows:

The running effect is as follows:

The Code is as follows:

<? Php/** Created on August */SimCalendar ('1970-08 '); // display the Calendar function SimCalendar ($ date) for the month {/*** simple calendar output, this function requires the support of cal_days_in_month * @ param $ date Y-m to output the date */echo '<table border = "1"> <thead> <tr> <th> day </th> <th> 1 </th> <th> 2 </th> <th> 3 </th> <th> 4 </th> <th> 5 </th> <th> 6 </th> </tr> </thead> <tbody> '; $ date_array = explode ('-', $ date); $ start_week = 0; // The value starts from Sunday to 0 $ month = cal_days_in_month (CAL_GREGORIA N, $ date_array [1], $ date_array [0]); // number of days in the current month $ wstar = date ('w', strtotime ($ date. '-01'); // the current month starts from the day of the week $ rows = ceil ($ wstar + $ month)/7); // The total number of rows $ mday = 1; // for ($ I = 0; $ I <$ rows; $ I ++) {echo '<tr>'; for ($ d = 0; $ d <7; $ d ++) {$ nowday = 7 * $ I + $ d + $ start_week; if ($ nowday >=$ wstar & $ mday <= $ month) {$ temp = date ('D', strtotime ($ date. '-'. $ mday); echo '<td> '. $ temp. '</td>'; $ mday ++ ;} Else {echo '<td> </td>';} echo '</tr> ';} echo '</tbody> </table>';}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.