Naptár funkció - CSS-trükkök

Anonim
 "; $calendar .= "$monthName $year"; $calendar .= ""; // Create the calendar headers foreach($daysOfWeek as $day) ( $calendar .= "$day"; ) // Create the rest of the calendar // Initiate the day counter, starting with the 1st. $currentDay = 1; $calendar .= ""; // The variable $dayOfWeek is used to // ensure that the calendar // display consists of exactly 7 columns. if ($dayOfWeek > 0) ( $calendar .= " "; ) $month = str_pad($month, 2, "0", STR_PAD_LEFT); while ($currentDay <= $numberDays) ( // Seventh column (Saturday) reached. Start a new row. if ($dayOfWeek == 7) ( $dayOfWeek = 0; $calendar .= ""; ) $currentDayRel = str_pad($currentDay, 2, "0", STR_PAD_LEFT); $date = "$year-$month-$currentDayRel"; $calendar .= "$currentDay"; // Increment counters $currentDay++; $dayOfWeek++; ) // Complete the row of the last week in month, if necessary if ($dayOfWeek != 7) ( $remainingDays = 7 - $dayOfWeek; $calendar .= " "; ) $calendar .= ""; $calendar .= ""; return $calendar; ) ?>

Használat

Táblázat kinyomtatásához 2005. májusában tegye a következőket:

És kap egy ilyen táblázatot:

2005. május
S M T W T F S
1 2 3 4 5. 6. 7
8. 9. 10. 11. 12. 13. 14
15 16. 17. 18. 19. 20 21
22. 23 24. 25 26. 27. 28.
29. 30 31