PHP Simple Calendar Implementation method _php tips

Source: Internet
Author: User

This article describes the PHP simple calendar implementation method. Share to everyone for your reference, specific as follows:

The screenshot of the running effect is as follows:

The specific code is as follows:

<?php/* Created on 2016-7-20/Simcalendar (' 2016-08 ');//display August calendar function Simcalendar ($date) {/** * simple calendar output, This function requires cal_days_in_month support * @param $date y-m The date to be exported * * echo ' <table border= ' 1 ' > <thead> &LT;TR&G
      T <th> Day </th> <th> one </th> <th> two </th> <th> three </th> <th > Four </th> <th> five </th> <th> six </th> </tr> </thead> <tbody&gt
    ;';
    $date _array = Explode ('-', $date); $start _week = 0;//starting from Sunday for 0 $month = Cal_days_in_month (Cal_gregorian, $date _array[1], $date _array[0]);//days of the month $wsta R = Date (' W ', Strtotime ($date.  '-01 '); $rows = Ceil (($wstar + $month)/7), or the total number of rows $mday = 1;//days 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> ';

 }?>

For more information about PHP interested readers can view the site topics: "PHP date and Time usage summary", "PHP object-oriented Program Design Primer", "PHP Mathematical Operation Skills Summary", "PHP Array" Operation Techniques Encyclopedia, "PHP Data structure and algorithm tutorial", " Summary of PHP programming algorithm and the summary of common PHP database operation skills

I hope this article will help you with the PHP program design.

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.