note 52574 added to ref.datetime

From: Date: Fri, 06 May 2005 07:33:44 +0000
Subject: note 52574 added to ref.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-88989@lists.php.net to get a copy of this message
Function generate one month calendar like February Mon Tue Wed Thu Fri Sat Sun 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 (default in russian locale) <?php $year = (int)$_GET["year"]; $month = (int)$_GET["month"]; draw_month_cal($year, $month); function draw_month_cal($year, $month, $locale = array ('ru_RU.CP1251', 'rus_RUS.1251')) { if (checkdate($month, 1, $year) && setlocale (LC_TIME, $locale)) { if (!$day = date("w", $f_day = mktime(0, 0, 0, $month, 1, $year))) $day = 7; // Mon first, Sun last print "<table border=0><tr><th colspan=7>" . strftime("%B", $f_day) . "</td></tr><tr>"; // Month for ($i = 8; --$i;) print "<th>" . strftime("%a", mktime(0, 0, 0, $month, 16 - $i - $day, $year)) . "</th>"; // Mon Tue Wed Thu Fri Sat Sun print "</tr><tr>" . str_repeat("<td></td>", --$day); // Empty cells while (checkdate($month, ++$i, $year)) { // $i==0 after for :-) print "<td>$i</td>"; if (!(++$day % 7)) print "</tr><tr>"; // next line after Sun } print "</tr></table>"; } } ?> ---- Manual Page -- http://www.php.net/manual/en/ref.datetime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52574 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52574&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52574&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52574&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52574&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52574&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52574&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88989) next »