//前幾天需要個萬年歷函數,在oso上看了個萬年歷,程序功能到是強大,只不過太繁瑣。
//不合自己的要求,因此就自己寫了一個,還可以給日期加上連接!
function calendar($year,$moon){
$moon1=array("01","02","03","04","05","06","07","08","09","10","11","12");
$moon2=array("31","28","31","30","31","30","31","31","30","31","30","31");
if(($year-2000)%4==0){$moon2[1]=29;}
for($i=0;$i<=11;$i++){
if($moon1[$i]==$moon){
$total=$moon2[$i];
}
}
$out_chat="";
$out_chat.="日一二三四五六";
for($i=1;$i<=$total;$i++){
$j=$i;
if($i<10){
$j="0".$i;
}
$time_array=getdate(mktime(0,0,0,$moon,$j,$year));
if($i==1){
switch($time_array[wday]){
case "0":
$out_chat.="".$i."";
break;
case "1":
$out_chat.=" ".$i."";
break;
case "2":
$out_chat.=" ".$i."";
break;
case "3":
$out_chat.=" ".$i."";
break;
case "4":
$out_chat.=" ".$i."";
break;
case "5":
$out_chat.=" ".$i."";
break;
case "6":
$out_chat.=" ".$i."";
break;
}
}else{
if($i!=$total){
if($time_array[wday]!=0){
$out_chat.="".$i."";
}else{
$out_chat.="".$i."";
}
}elseif($i==$total){
switch($time_array[wday]){
case "0":
$out_chat.="".$i." ";
break;
case "1":
$out_chat.="".$i." ";
break;
case "2":
$out_chat.="".$i." ";
break;
case "3":
$out_chat.="".$i." ";
break;
case "4":
$out_chat.="".$i." ";
break;
case "5":
$out_chat.="".$i." ";
break;
case "6":
$out_chat.="".$i."";
break;
}
}
}
}
$out_chat.="";
return $out_chat;
}
$year=2000;
$moon=08;
$test=calendar($year,$moon);
echo $test;
?>