//前几天需要个万年历函数,在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;$iif($moon1[$i]==$moon){
$total=$moon2[$i];
}
}
$out_chat="";
$out_chat.="日一二三四五六";
for($i=1;$i$j=$i;
if($i$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;
?>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn