Today, in the program era, everything is solved with a program. Of course it is very convenient. So, you ask me October 1, 2003 is the day of the week, I will probably directly use the program to tell you.
echo Date (' W ', Strtotime (' 2003-10-1 '));
But in fact, we all know that PHP's date function has a time range, that is, only from 1970-2038 years, so the algorithm outside the range is not allowed. How do you calculate the bottom? In fact, there is a formula:
Caille (Zeller) formula: w=y+[y/4]+[c/4]-2c+[26 (m+1)/10]+d-1
The meanings of the symbols in the formula are as follows, W: week; C: Century -1;y: Year (two digits); M: month (m greater than or equal to 3, less than or equal to 14, that is, in the Caille formula, the December of the year is counted as the previous year's 13, 1 April, For example, January 1, 2003 should be considered as the 2002 1 March 1 to calculate); D: day; [] represents rounding, that is, as long as the integer part. (c is the century minus one, y is two digits after the year, M is the month, and D is the number of days. January and February are calculated according to the previous year's 1 March and 1 April, when both C and Y are valued for the previous year. )
The calculated W divided by 7, the remainder is a few weeks. If the remainder is 0, it is Sunday.
Taking October 1, 2049 (National Day of the 100 anniversary) as an example, the Caille (Zeller) formula is used to calculate the process as follows:
Caille (Zeller) formula: w=y+[y/4]+[c/4]-2c+[26 (m+1)/10]+d-1
=49+[49/4]+[20/4]-2x20+[26x (10+1)/10]+1-1
=49+[12.25]+5-40+[28.6]
=49+12+5-40+28
=54 (divided by more than 7 5)
namely October 1, 2049 (100 Anniversary National Day) is the Week 5.
What is your birthday (at birth, this year, next year)? Give it a try.
Day of the week according to the date