*{margin:0;padding:0;list-style-type:none;font-family:"微软雅黑";}
td,th{text-align:center;height:30px;width:40px;line-height:30px;}
th{background:#CCCCCC;}
.week{background:#FFCC33;}
table{border:1px solid #06F;background:#0CF;}
header("content-type:text/html;charset=utf-8");
class Calendar
{
private $year;
private $month;
private $day_week;
private $start = 1970;
private $stop = 2036;
private $weeks = array("日", "一", "二", "三", "四", "五", "六");
private $months = array("01" => "一月", "02" => "二月", "03" => "三月",
"04" => "四月", "05" => "五月", "06" => "六月", "07" => "七月", "08" => "八月",
"09" => "九月", "10" => "十月", "11" => "十一月", "12" => "十二月");
function __construct(){
$this->year=isset($_POST['year']) ? $_POST['year'] : date("Y");
$this->month=isset($_POST['month']) ? $_POST['month'] : date("m");
$this->day_week=date("w", mktime(0, 0, 0, $this->month, 1, $this->year));
}
private function getymd(){
echo "
";for($i=$this->start;$i<=$this->stop;$i++){
if (strcmp($i, $this->year) == 0) {
$select = "selected style='background-color:#c0c0c0'";
} else {
$select = "";
}
echo "".$i."";
}
echo "
";echo "
".$this->year."年".$this->month."月".date("d",time()+3600*8)."";echo "
";foreach($this->months as $k=>$v){
if (strcmp($k, $this->month) == 0) {
$select = "selected style='background-color:#c0c0c0'";
} else {
$select = "";
}
echo "".$v."";
}
echo "
";}
private function getweek(){
echo "
";foreach($this->weeks as $v){
echo "
".$v."";}
echo "
";}
private function getdates(){
echo "
";for($i=0; $iday_week; $i++){
echo "
";}
for($j=1; $j <= date("t", mktime(0, 0, 0, $this->month, 1, $this->year)); $j++){
$i++;
if($j == date("d")){
echo "
".$j."";}else{
echo "
".$j."";}
if($i%7 == 0){
echo "
";}
}
while($i%7 != 0){
echo "
";$i++;
}
}
function run(){
echo "
$this->getymd();
$this->getweek();
$this->getdates();
echo "
";}
}
$d = new Calendar();
$d->run();
?>