PHP handwritten calendar code-PHP source code

Source: Internet
Author: User
PHP handwritten calendar code

[PHP] code
$ Monthnow = isset ($ _ GET ['mon'])? $ _ GET ['mon']: date ("n"); $ yearnow = isset ($ _ GET ['Year'])? $ _ GET ['Year']: date ("Y"); if ($ monthnow = 13) {$ monthnow = 1; $ yearnow = $ yearnow + 1 ;} if ($ monthnow = 0) {$ monthnow = 12; $ yearnow = $ yearnow-1;} $ mdays = date ("t "); // total number of days in the current month $ datenow = date ("j"); // date of the current day // calculate the number of days in the first day of the current month $ wk1st = date ("w", mktime, 0, $ monthnow, 1, $ yearnow); $ trnum = ceil ($ mdays + $ wk1st)/7 ); // calculate the number of rows in the table // The Table string $ tabstr ="
 ". $ Dayecho ."
 
  
"; $ Tabstr. ="
  "; $ Tabstr. ="
   "; For ($ I = 0; $ I <$ trnum; $ I ++) {$ tabstr. ="
   
    
"; // Seven cells in each row for ($ k = 0; $ k <7; $ k ++) {// Obtain the cell sequence number $ tabidx = $ I * 7 + $ k; // if the cell sequence number is less than the number of weeks on the first day of the month ($ wk1st) or greater than (total number of months + $ wk1st), just fill in space, otherwise, write Date ($ tabidx <$ wk1st or $ tabidx> $ mdays + $ wk1st-1 )? $ Dayecho = "& nbsp": $ dayecho = $ tabidx-$ wk1st + 1; // highlight the date of today if ($ dayecho! = '& Nbsp') {$ num = $ dayecho; if ($ dayecho = $ datenow) $ dayecho =""; $ Tabstr. ='
    ";} Else {$ tabstr. ='
    ";}}$ Tabstr. ="
   ";}$ Tabstr. ="
  
< "; $ Tabstr. = $ yearnow. 'year'. $ monthnow. 'month'. date ('D', time ()." "; $ Tabstr. =" >>>
Day I II 3. Thu V. Sat.
'. $ Dayecho ."
"; Print $ tabstr; // output calendar

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.