您好,欢迎访问一九零五行业门户网

日历类

日历
一月,
            02=>二月,
            03=>三月,
            04=>四月,
            05=>五月,
            06=>六月,
            07=>七月,
            08=>八月,
            09=>九月,
            10=>十月,
            11=>十一月,
            12=>十二月
        );
//设置年份
    function setyear($year){
        $this->year=$year;
    }
    //获得年份
    function getyear(){
        return $this->year;
    }
    //设置月份
    function setmonth($month){
        $this->month=$month;
    }
    //获得月份
    function getmonth(){
        return $this->month;
    }
    //设置日期
    function setday($day){
        $this->day=$day;
    }
    //获得日期
    function getday(){
        return $this->day;
    }
    //打印日历
    function out(){
        $this->_env();
        $week=$this->getweek($this->year,$this->month,$this->day);//获得日期为星期几 (例如今天为2003-07-18,星期五)
        $fweek=$this->getweek($this->year,$this->month,1);//获得此月第一天为星期几
        echo
;
for($ttmpa=1;$ttmpa            $ttmpb=sprintf(%02d,$ttmpa);
            if(strcmp($ttmpb,$this->month)==0){
                $select=selected style=\background-color:#c0c0c0\;
            }else{
                $select=;
            }
            echo .$this->_month[$ttmpb].\r\n;
        }
echo      ;//打印年份,前后10年
        for($ctmpa=$this->year-10;$ctmpayear+10;$ctmpa++){
            if($ctmpa>2037){
                break;
            }
            if($ctmpa                continue;
            }
            if(strcmp($ctmpa,$this->year)==0){
                $select=selected style=\background-color:#c0c0c0\;
            }else{
                $select=;
            }
            echo $ctmpa\r\n;
        }
        echo
;
        for($tmpa=0;$tmpaweek);$tmpa++){//打印星期标头
            echo .$this->week[$tmpa];
        }
        for($tmpb=1;$tmpbmonth,$this->day,$this->year));$tmpb++){//打印所有日期
            if(strcmp($tmpb,$this->day)==0){    //获得当前日期,做标记
                $flag= bgcolor='#ff0000';
            }else{
                $flag=' bgcolor=#ffffff';
            }
            if($tmpb==1){        
                echo ;        //补充打印
                for($tmpc=0;$tmpc                    echo ;
                }
            }
            if(strcmp($this->getweek($this->year,$this->month,$tmpb),0)==0){
                echo
$tmpb;
            }else{
                echo $tmpb;
            }
        }
        echo
;
    }
    //获得方法内指定的日期的星期数
    function getweek($year,$month,$day){
        $week=date(w,mktime(0,0,0,$month,$day,$year));//获得星期
        return $week;//获得星期
    }
function _env(){
        if(isset($_post[month])){    //有指定月
            $month=$_post[month];
        }else{
            $month=date(m);    //默认为本月
        }
        if(isset($_post[year])){    //有指年
            $year=$_post[year];
        }else{
            $year=date(y);    //默认为本年
        }
    $this->setyear($year);
    $this->setmonth($month);
    $this->setday(date(d));
}
}
$d=new calendar;
$d->out();
?>
其它类似信息

推荐信息