简单的php教程日历类控件代码实例
/*
*/
date_default_timezone_set("Etc/GMT-8");
class Calendar{
var $T = array();
var $datesOFmonth = array('1'=>'31','2'=>'28','3'=>'31','4'=>'30','5'=>'31','6'=>'30','7'=>'31','8'=>'31','9'=>'30','10'=>'31','11'=>'30','12'=>'31');
var $Y,$M,$D;
function set($time){
$this->T = getdate($time);
$this->Y = $this->T['year'];
$this->M = $this->T['mon'];
$this->D = date('d',$time);
}
function isRun(){
return ($this->Y%400==0 || ($this->Y%4==0 && $this->Y%100==0)) ? 1 : 0;
}
function first(){
$time = mktime(0,0,0,$this->M,1,$this->Y);
$time = getdate($time);
return $time['wday'];
}
function html(){
$isRun = $this->isRun();
$this->datesOFmonth[2] = $isRun==1 ? 29: 28;
$html .= "
上一月 | {$this->Y}年 {$this->M}月 | 下一月 | ||||
---|---|---|---|---|---|---|
星期天 | 星期一 | 星期二 | 星期三 | 星期四 | 星期五 | 星期六 |
"; | $i | ";|||||
"; |
$calendar = new Calendar();
$calendar->set(time());
echo $calendar->html();