[Post] PHP century perpetual calendar _ PHP Tutorial

Source: Internet
Author: User
[Post] PHP century calendar .? Century calendar # This is the only setting-enter the location of the php file $ file192.168.1.168phprls2m. php; # The number of days of the lunar calendar month $ everymontharray (0 array (8, 0, 0, 0, 0, 0, 0 // Calendar of the century
# This is the only setting-enter the location of the PHP file
$ File = "http: // 192.168.1.168/php/rl/s2m. php ";
// # Number of days of the lunar calendar month
$ Everymonth = array (
0 => array ),
1 => array ),
2 => array (, 3 ),
3 => array ),
4 => array ),
5 => array ),
6 => array ),
7 => array ),
8 => array ),
9 => array ),
10 => array ),
11 => array (6, 30, 29, 30, 29, 30, 29, 29, 29, 30, 29, 30, 30, 8, 12 ),
12 => array ),
13 => array ),
14 => array ),
15 => array ),
16 => array ),
17 => array (, 29,29, 30,29, 30,30, 29,30, 30,29, 30,29 ),
18 => array (, 29,29, 30,29, 30,29, 30,30, 29,30, 30,0, 5, 7 ),
19 => array ),
20 => array ),
21 => array ),
22 => array ),
23 => array ),
24 => array ),
25 => array ),
26 => array (, 3 ),
27 => array (, 29,29, 30,29, 30,29, 30,29, 30,30, 30,0 ),
28 => array ),
29 => array ),
30 => array (6, 29, 30, 30, 29, 30, 29, 29, 29, 30, 30, 29, 7 ),
31 => array ),
32 => array ),
33 => array (5, 29, 30, 30, 29, 30, 29, 30, 29, 29, 30, 10, 10 ),
34 => array ),
35 => array ),
36 => array (3,30, 29,29, 30,29, 29,30, 30,29, 30,30, 30,29, 3,1 ),
37 => array ),
38 => array ),
39 => array ),
40 => array ),
41 => array (6, 30, 30, 29, 30, 30, 29, 30, 29, 29, 29, 29, 8, 6 ),
42 => array ),
43 => array ),
44 => array ),
45 => array ),
46 => array ),
47 => array ),
48 => array ),
49 => array ),
50 => array ),
51 => array ),
52 => array (5, 29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 9, 5 ),
53 => array ),
54 => array ),
55 => array ),
56 => array ),
57 => array ),
58 => array ),
59 => array ),
60 => array (6,30, 29,30, 29,30, 30,29, 30,29, 30,29, 30,29, 30,29, 7,1 ),
61 => array ),
62 => array ),
63 => array ),
64 => array ),
65 => array ),
66 => array ),
67 => array ),
68 => array ),
69 => array ),
70 => array (, 29,29, 30,29, 30,30, 29,30, 30,29, 30,0 ),
71 => array ),
72 => array ),
73 => array ),
74 => array ),
75 => array ),
76 => array (8, 30, 29, 30, 29, 30, 29, 30, 29, 29, 30, 3, 5 ),
77 => array ),
78 => array ),
79 => array (6, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29, 30, 29, 6, 8 ),
80 => array ),
81 => array ),
82 => array ),
83 => array (, 12 ),
84 => array ),
85 => array ),
86 => array (, 3 ),
87 => array (6, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 29, 4, 4 ),
88 => array ),
89 => array (, 29,29, 30,29, 29,30, 30,29, 30,30, 30,0, 6 ),
90 => array ),
91 => array ),
92 => array (, 30, 30, 29, 30, 29, 29, 29, 30, 30, 30, 0, 9, 9 ),
93 => array (, 10, 10 ),
94 => array ),
95 => array ),
96 => array ),
97 => array ),
98 => array ),
99 => array ),
100 => array ),
101 => array ),
102 => array ),
103 => array ),
104 => array ),
105 => array ),
106 => array ),
107 => array ),
108 => array ),
109 => array ),
110 => array ),
111 => array ),
112 => array ),
113 => array ),
114 => array (9,29, 30,29, 30,29, 30,29, 30,30, 29,30, 29,30 ),
115 => array ),
116 => array ),
117 => array ),
118 => array ),
119 => array ),
120 => array)
);
##############################
# Lunar calendar
$ Mten = array ("null", "a", "B", "C", "Ding", "E", "Ji", "Geng ", "Xin", "Shen", "Xi ");
# Lunar calendar
$ Mtwelve = array ("null", "Child (RAT)", "ugly (cow)", "Yin (Tiger)", "Mao (rabbit )", "Chen (Dragon )",
"Si (snake)", "Wu (horse)", "Wei (goat)", "Shen (monkey)", "you (chicken)", "Shen (dog) "," Hai (pig )");
# Lunar month
$ Mmonth = array ("Hangzhou", "Zheng", "two", "three", "four", "five", "six ",
"7", "8", "9", "10", "11", "12", "month ");
# Lunar calendar day
$ Mday = array ("null", "First Day", "second day", "Third Day", "fourth day", "Fifth Day", "Sixth Day", "Seventh Day ", "Eighth Day", "Ninth Day", "Tenth Day ",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20 ",
"Jun 1", "Jun 2", "Jun 3", "Jun 4", "Jun 5", "Jun 6", "Jun 7", "Jun 8 ", "9th", "30th ");
##############################
# Assign an initial value
# Tiangan land support
$ Ten = 0;
$ Twelve = 0;
# Weeks
$ Week = 5;
# Lunar calendar day
$ Md = 0;
# Lunar month
$ Mm = 0;
# The total number of days of the Gregorian calendar to January 1, December 21, 1900
$ Total = 11;
# Total calendar days
$ Mtotal = 0;
##############################
# Obtain the date of the current day
$ Today = getdate ();
# If no value is entered, set it to the date of the current day.
If ($ year = "" or $ month = "" or ($ year <1901 or $ year> 2020)
Or ($ month <1 or $ month> 12 )){
$ Year = $ today [year];
$ Month = $ today [mon];
}
##############################
# Calculate the total number of days of the expected date Solar Calendar-From January 1, December 21, 1900
# Calculate the sum of years first
For ($ y = 1901; $ y <$ year; $ y ++ ){
$ Total + = 365;
If ($ y % 4 = 0) $ total ++;
}
# Plus a few months of the current year
Switch ($ month ){
Case 12:
$ Total + = 30;
Case 11:
$ Total + = 31;
Case 10:
$ Total + = 30;
Case 9:
$ Total + = 31;
Case 8:
$ Total + = 31;
Case 7:
$ Total + = 30;
Case 6:
$ Total + = 31;
Case 5:
$ Total + = 30;
Case 4:
$ Total + = 31;
Case 3:
$ Total + = 28;
Case 2:
$ Total + = 31;
}
# Add one day for a leap year
If ($ year % 4 = 0 and $ month> 2 ){
$ Total ++;
}
# Calculate the day of the month by the way
$ Week = ($ total + $ week) % 7;
##############################
# Use the number of days in the lunar calendar to determine whether the number of days exceeds the number of days in the Gregorian calendar
$ Flag1 = 0; # determine the condition for jumping out of the loop
$ J = 0;
While ($ j <= 120 ){
$ I = 1;
While ($ I <= 13 ){
$ Mtotal + = $ everymonth [$ j] [$ I];
If ($ mtotal >=$ total ){
$ Flag1 = 1;
Break;
}
$ I ++;
}
If ($ flag1 = 1) break;
$ J ++;
}



##############################
# Calculate the lunar date of the month 1
$ Md = $ everymonth [$ j] [$ I]-($ mtotal-$ total );
# Number of days that are blank in the first month
$ K = $ week;
# Crossing a year
Switch ($ month ){
Case 1:
Case 3:
Case 5:
Case 7:
Case 8:
Case 10:
Case 12:
$ Dd = 31;
Break;
Case 4:
Case 6:
Case 9:
Case 11:
$ Dd = 30;
Break;
Case 2:
If ($ year % 4 = 0 ){
$ Dd = 29;
} Else {
$ Dd = 28;
}
Break;
}
# Crossing a year
$ Ty = 0;
If ($ everymonth [$ j] [0] <> 0 and $ I = 13) or ($ everymonth [$ j] [0] = 0 and $ I = 12 ))
And $ mtotal-$ total <$ dd) $ ty = 1;
?>


Century calendar



// Print the year/year head
Echo"

". $ Year." year ". $ month." month

\ N ";
If ($ ty = 0)
{
Echo"

". $ Mten [$ everymonth [$ j] [14]. $ mtwelve [$ everymonth [$ j] [15]." year

";
}
Else
{
Echo"

". $ Mten [$ everymonth [$ j] [14]. $ mtwelve [$ everymonth [$ j] [15]. "/". $ mten [$ everymonth [$ j + 1] [14]. $ mtwelve [$ everymonth [$ j + 1] [15]. "year

";
}
?>



































































$ Day = 1;$ Line = 0;While ($ day <= $ dd ){Echo" \ N ";For ($ s = 0; $ s <= 6; $ s ++ ){If ($ k <> 0 or $ day> $ dd ){Echo" \ N ";$ K --;} Else {// Set the character colorSwitch ($ s ){Case 1:Case 2:Case 3:Case 4:Case 5:$ Color = "#000000 ";Break;Case 0:$ Color = "# FF0000 ";Break;Case 6:$ Color = "#008000 ";Break;}# Generate a Chinese lunar calendarIf ($ md = 1) {#1 day print the monthIf ($ everymonth [$ j] [0] <> 0 and $ everymonth [$ j] [0] <$ I ){$ Mm = $ I-1;} Else {$ Mm = $ I;}If ($ I = $ everymonth [$ j] [0] + 1 and $ everymonth [$ j] [0] <> 0) $ chi = $ mmonth [0]. $ mmonth [$ mm]; # leap monthElse $ chi = $ mmonth [$ mm]. $ mmonth [13];} Else {$ Chi = $ mday [$ md];}Echo" \ N ";$ Day ++;$ Md ++;If ($ md> $ everymonth [$ j] [$ I]) {$ Md = 1;$ I ++;}If ($ I> 12 and $ everymonth [$ j] [0] = 0) or ($ I> 13 and $ everymonth [$ j] [0] <> 0 )){$ I = 1;$ J ++;}}}Echo" \ N ";$ Line ++;}?>
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
 $ Day $ Chi



# Complementing empty rows
For ($ l = 1; $ l <= (6-$ line); $ l ++ ){
Echo"



\ N ";Echo" \ N ";Echo" \ N ";Echo" \ N ";Echo"
A
\ N ";
}
# Printed on July 15, January and next July 15, January
$ Ly = $ ny = $ year;
$ Last = $ month-1;
If ($ last = 0 ){
$ Last = 12;
$ Ly --;
}
$ Next = $ month + 1;
If ($ next = 13 ){
$ Next = 1;
$ Ny ++;
}
If ($ ly> = 1901)
Echo"

< <上一个月 \n";
Else
Echo"

";
If ($ ny<= 2020)
Echo "next month>

\ N ";
?>
Echo"

Http://www.bkjia.com/PHPjc/317345.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/317345.htmlTechArticle? // Century perpetual calendar # This is the only setting-enter the location of the php file $ file = "http: // 192.168.1.168/php/rl/s2m. php "; // # The number of days of the lunar calendar month $ everymonth = array (0 = array (8, 0, 0, 0, 0, 0...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.