Simple PHP calendar algorithm-PHP Tutorial

Source: Internet
Author: User
Simple PHP calendar algorithm. * ** Calendar ** Copyright (c) 2007by Chen Yixin (Deep Space ). allrightsreserved * Tocontacttheauthorwriteto {@ linkmailto: shenkong@php.net} * @ author Chen Yixin (Deep Space) * if (fu /**
* Calendar
*
* Copyright (c) 2007 by Chen Yixin (Deep Space). All rights reserved
* To contact the author write to {@ link mailto: shenkong@php.net}
* @ Author Chen Yixin (Deep Space)
*/
If (function_exists ('date _ default_timezone_set ')){
Date_default_timezone_set ('Asia/Chongqing ');
}
$ Date = isset ($ _ GET ['Date'])? $ _ GET ['Date']: date ('Y-m-D ');
$ Date = getdate (strtotime ($ date ));
$ End = getdate (mktime (0, 0, 0, $ date ['mon'] + 1, 1, $ date ['Year'])-1 );
$ Start = getdate (mktime (0, 0, 0, $ date ['mon'], 1, $ date ['Year']);
$ Pre = date ('Y-m-D', $ start [0]-1 );
$ Next = date ('Y-m-D', $ end [0] + 86400 );
$ Html ='
































';$ Html. =' ';$ Html. =' ';$ Html. =' ';$ Html. =' ';$ Html. =' ';$ Arr_tpl = array (0 => '', 1 =>'', 2 => '', 3 =>'', 4 => '', 5 => '', 6 => '');$ Date_arr = array ();$ J = 0;For ($ I = 0; $ I <$ end ['mday']; $ I ++ ){If (! Isset ($ date_arr [$ j]) {$ Date_arr [$ j] = $ arr_tpl;}$ Date_arr [$ j] [($ I + $ start ['wday']) % 7] = $ I + 1;If ($ date_arr [$ j] [6]) {$ J ++;}}Foreach ($ date_arr as $ value ){$ Html. =' ';Foreach ($ value as $ v ){If ($ v ){If ($ v = $ date ['mday']) {$ Html. =' ';} Else {$ Html. =' ';}} Else {$ Html. =' ';}}$ Html. =' ';}$ Html. ='
-'. $ Date ['Year'].'; '. $ date ['month'].'+
'. $ V .''. $ V .' 
';
Echo $ html;

Calendar * calendar ** Copyright (c) 2007 by Chen Yixin (Deep Space ). all rights reserved * To contact the author write to {@ link mailto: shenkong@php.net} * @ author Chen Yixin (Deep Space) */if (fu...

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.