Calendar Display project_php-PHP Tutorial

Source: Internet
Author: User
? Php $ selectedDaydate (d); $ selectedMonthdate (m); $ selectedYeardate (Y); obtain the number of days in a numeric week on the first day of the month $ firstdaydate (w, mktime (0, 0, 0, $ selectedMonth, 1, $ selectedYear); find the last day of the month $ lastday31; do {$ monthOrigdate (m $ SelectedDay = date ('D ');
$ SelectedMonth = date ('M ');
$ SelectedYear = date ('Y ');
// Obtain the number of days of the week in the numeric format on the first day of the month.
$ Firstday = date ('W', mktime (0, 0, 0, $ selectedMonth, 1, $ selectedYear ));
// Find the last day of the month
$ Lastday = 31;
Do {
$ MonthOrig = date ('M', mktime (0, 0, 0, $ selectedMonth, 1, $ selectedYear ));
$ MonthTest = date ('M', mktime (0, 0, 0, $ selectedMonth, $ lastday, $ selectedYear ));
If ($ monthTest! = $ MonthOrig) {$ lastday-= 1 ;}
} While ($ monthTest! = $ MonthOrig );
// Obtain the English name of the current month
$ MonthName = date ('F', mktime (0, 0, 0, $ selectedMonth, 1, $ selectedYear ));
// Display the calendar header
$ Days = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday ");
$ DayRow = 0;
Print ("



























");Print (" ");Print (" \ N ");For ($ I = 0; $ I <= 6; $ I ++ ){Print (" \ N ");}Print (" \ N ");Print (" \ N ");// Empty the first day of the current month.While ($ dayRow <$ firstday ){Print (" ");$ DayRow + = 1;}$ Day = 0;While ($ day <$ lastday ){// The following judgment statement is used to convert each 7 time positions to the next lineIf ($ dayRow % 7) = 0 ){Print (" \ N \ N ");}$ Adjusted_day = $ day + 1;// Display the date of the current day in redIf ($ adjusted_day ==$ selectedDay ){Echo" ";}Else {echo" ";}$ Day + = 1;$ DayRow + = 1;}Print ("\ n \ N
$ MonthName $ selectedYear
$ Days [$ I]
$ Adjusted_day$ Adjusted_day
");
?>

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.