October 2010 Calendar php generate monthly calendar code

Source: Internet
Author: User
/*
Function written by Nelson Neoh @3/2004.
For the those who wants to utilize this code, please do not remove the this remark.
If you had done a enhancement to this code, please post the copy at Http://www.dev-club.com PHP board. Thank.
Function Usage:calendar (month,year)
*/
function Calendar ($MM, $YYYY) {
if ($MM = = "") $MM = Date ("M");
if ($YYYY = = "") $YYYY = Date ("Y");
if (Checkdate ($MM, 1, $YYYY)) {
$stringDate = Strftime ("%d%b%Y", Mktime (0,0,0, $MM, 1, $YYYY));
$days = strftime ("%d", Mktime (0,0,0, $MM +1,0, $YYYY));
$firstDay = strftime ("%w", Mktime (0,0,0, $MM, 1, $YYYY));
$lastDay = strftime ("%w", Mktime (0,0,0, $MM, $days, $YYYY));
$printDays = $days;
$preMonth = strftime ("%m", Mktime (0,0,0, $MM -1,1, $YYYY));
$preYear = strftime ("%Y", Mktime (0,0,0, $MM -1,1, $YYYY));
$nextMonth = strftime ("%m", Mktime (0,0,0, $MM +1,1, $YYYY));
$nextYear = strftime ("%Y", Mktime (0,0,0, $MM +1,1, $YYYY));
Print ("





































");Print (" "); Print (" Print (" ");Print (" "); Print (" ");$currentDays = 1;for ($a =1; $a <=5; $a + +) {Print (" "); $diffDays = $firstDay-$lastDay; if ($firstDay > $lastDay && $currentDays ==1 && ($diffDays <>1)) {for ($x = $lastDay; $x >=0; $x-- {$printDays = $days-$x; Print (" "); } for ($z =1; $z < $firstDay-$lastDay; $z + +) {print (" "); } for ($y = $firstDay; $y <7; $y + +) {print (" "); $currentDays + +; }} elseif ($firstDay!=0 && $currentDays ==1) {for ($z =1; $z <= $firstDay; $z + +) {print (" "); } for ($y = $firstDay; $y <7; $y + +) {print (" "); $currentDays + +; }} else {for $u =1; $u <=7 && $currentDays <= $days; $u + +) {print (" "); $currentDays + +; }} print (" ");}Print ("
P". Strftime ("%b%Y", Mktime (0,0,0, $MM, 1, $YYYY)).N
Sun Mon Tue Wed Thu Fri Sat
$printDays$currentDays$currentDays$currentDays
");
}
}
?>

The above describes the October 2010 calendar PHP generated monthly calendar code, including the October 2010 calendar content, I hope to be interested in PHP tutorial friends helpful.

  • 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.