Home > Backend Development > PHP Tutorial > Simple perpetual calendar function_PHP tutorial

Simple perpetual calendar function_PHP tutorial

WBOY
Release: 2016-07-13 17:23:36
Original
905 people have browsed it


//I needed a perpetual calendar function a few days ago, and I saw a perpetual calendar on oso. The program is very powerful, but too cumbersome.
//It didn’t meet my requirements, so I wrote one myself. You can also add a link to the date!
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;
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532214.htmlTechArticle//I needed a perpetual calendar function a few days ago. I saw a perpetual calendar on oso. The program is very powerful. It's just too cumbersome. //It doesn’t meet my requirements, so I wrote one myself, which is okay...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template