Make a calendar program

Source: Internet
Author: User

calendar.class.php

<?Phpdate_default_timezone_set (' PRC ');classcalendar{Private $year;//the current year    Private $month;//the current month    Private $day;//the current day    Private $start _weekday;//the first day of the month is the week    Private $days;//The current month altogether how many days    function__construct () {//get the current year        $this->year=isset($_get[' Year '])?$_get[' Year ']:Date("Y"); //get the current month        $this->month=isset($_get[' Month '])?$_get[' Month ']:Date("M"); //get the current day        $this->day=Date("D"); //get the number of days this month        $this->start_weekday=Date("W",Mktime(0,0,0,$this->month,1,$this-Year )); //The first day of the month to get started is the days of the week        $this->days=Date("T",Mktime(0,0,0,$this->month,1,$this-Year )); }    functionout () {Echo' <table align= ' center > '; //call a function that changes the year and month        $this->changedate ("test.php"); //Call Week list        $this-weekslist (); //Call Date list        $this-dayslist (); Echo' </table> '; }    Private functionweekslist () {//Create a week array        $week=Array(' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' VI '); Echo' <tr> '; //Output Week Array         for($i= 0;$i<Count($week);$i++){            Echo' <th class= ' fontb ' > '.$week[$i].‘ </th> '; }        Echo' </tr> '; }    Private functiondayslist () {Echo' <tr> '; //output space (currently one months in front of empty)         for($j= 0;$j<$this->start_weekday;$j++){            Echo' <td>&nbsp;</td> '; }        //output this month's date         for($k= 1;$k<$this->days;$k++){            $j++; if($k==$this-Day )Echo' <td class= ' fontb ' > '.$k.‘ </td> '; Else                Echo' <td> '.$k.‘ </td> '; if($j%7==0)                Echo' </tr><tr> '; }        //the space behind         while($j%7!=0){            Echo' <td>&nbsp;</td> '; $j++; }        Echo' </tr> '; }    Private functionPrevyear ($year,$month){        $year=$year-1; if($year< 1970)            $year=1970; return"Year={$year}&month={$month}"; }    Private functionPrevmonth ($year,$month){        if($month==1){            $year=$year-1; if($year< 1970)                $year=1970; $month=1; }Else{            $month--; }        return"Year={$year}&month={$month}"; }    Private functionNextyear ($year,$month){        $year=$year+1; if($year> 2038)            $year=2038; return"Year={$year}&month={$month}"; }    Private functionNextmonth ($year,$month){        if($month==12){            $year=$year+1; if($year> 2038)                $year=2038; $month=12; }Else{            $month++; }        return"Year={$year}&month={$month}"; }    Private functionChangeDate ($url=""){        Echo' <tr> ';        Echo' <td colspan= ' 7 "> '; Echo' <form> '; Echo' <select name= ' year ' onchange= ' window.location=\ '.$url.‘? Year=\ ' +this.options[selectedindex].value+\ ' &month= '.$this->month. ' \ ' > ';  for($sy= 1970;$sy<= 2038;$sy++){            $selected= ($sy==$this->year)? "Selected": ""; Echo' <option '.$selected. ' Value= '.$sy.‘" > '.$sy.‘ </option> '; }        Echo' </select> '; Echo' <select name= ' month ' onchange= ' window.location=\ '.$url.‘? Year= '.$this->year. ' &month=\ ' +this.options[selectedindex].value ' > ';  for($SM= 1;$SM<=12;$SM++){            $selected 1= ($SM==$this->month)? "Selected": ""; Echo' <option '.$selected 1. ' Value= '.$SM.‘" > '.$SM.‘ </option> '; }        Echo' </select> '; Echo' </form> '; Echo' </td> ';        Echo' </tr> '; }}?>

calendar.php

<style>table{Border: 1px solid#050;    }    .fontb{Color:White ; Background:Blue; } th,td{Text-align:Center; Width:30px; Height:30px; } form{margin:0px; Padding:0px; } select{Text-align:Center; }</style><?PHP//include class fileinclude"./calendar.class.php";//To Create a class object$calendar=NewCalendar;$calendar-out ();?>

Make a calendar program

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.