Copy CodeThe code is as follows:
Class calendar{
/*
* Www.jb51.net Revised version
*/
var $YEAR, $MONTH, $DAY;
var $WEEK =array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var $_month=array (
"He", "January",
"The" and "February",
"A" and "March",
"" "and" April ",
"" "and" May ",
"He" and "June",
"" and "July",
"He" and "August",
"He" and "September",
"Ten" = "October",
"One" = "November",
"A" and "December"
);
Set year
function Setyear ($year) {
$this->year= $year;
}
Year of acquisition
function GetYear () {
return $this->year;
}
Set month
function Setmonth ($month) {
$this->month= $month;
}
Get month
function GetMonth () {
return $this->month;
}
Set Date
function Setday ($day) {
$this->day= $day;
}
Date obtained
function GetDay () {
return $this->day;
}
Print a calendar
function out () {
$this->_env ();
$week = $this->getweek ($this->year, $this->month, $this->day);//Get date for day of the week (for example today for 2003-07-18, Friday)
$fweek = $this->getweek ($this->year, $this->month,1); Get the first day of the month for the week
echo "
WEEK) ($Tmpa + +) {//Print week header
echo "
"; for ($Tmpa =0; $Tmpa
". $this->week[$Tmpa]; } for ($TMPB =1; $TMPB <=date ("T", Mktime (0,0,0, $this->month, $this->day, $this->year)), $TMPB + +) {//Print all dates if (strcmp ($TMPB, $this->day) ==0) {//Get current date, Mark $flag = "bgcolor= ' #ff0000 '"; }else{ $flag = ' bgcolor= #ffffff '; } if ($TMPB ==1) { echo " |
"; Supplemental print for ($TMPC =0; $Tmpc < $fweek; $TMPC + +) {echo "
"; } } if (strcmp ($this->getweek ($this->year, $this->month, $TMPB), 0) ==0) { echo " |
$TMPB "; }else{ echo " |
$TMPB "; } } echo " |
";
}
Gets the number of weeks of the date specified in the method
function Getweek ($year, $month, $day) {
$week =date ("W", Mktime (0,0,0, $month, $day, $year));//Get Week
return $week;//Get Week
}
function _env () {
if (Isset ($_post["Month")) {//has a specified month
$month =$_post["Month"];
}else{
$month =date ("M"); Default is this month
}
if (Isset ($_post["Year")) {//refers to years
$year =$_post["Year"];
}else{
$year =date ("Y"); Default is this year
}
$this->setyear ($year);
$this->setmonth ($month);
$this->setday (Date ("D"));
}
}
$D =new Calendar;
$D->out ();
?>
http://www.bkjia.com/PHPjc/317183.html www.bkjia.com true http://www.bkjia.com/PHPjc/317183.html techarticle Copy the code as follows: PHP classcalendar{/* *www.jb51.net revision */Var$year, $MONTH, $DAY; Var$week=array ("Sunday", "Monday", "Tuesday", "Wednesday" , "Thursday", "Friday ...