ID:               46861
 Updated by:       j...@php.net
 Reported By:      john at designingforbusiness dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Date/time related
 Operating System: OS X, Ubantu
 PHP Version:      5.2.8
 New Comment:

Ever heard of date("t") ?


Previous Comments:
------------------------------------------------------------------------

[2008-12-14 03:27:54] john at designingforbusiness dot com

Description:
------------
While using date("d", mktime(0,0,0,11+1,0,2008); to retrieve the number
of days in November I continually have 29 returned. While December and
other months are correct.

Reproduce code:
---------------
foreach($this->vacationDays as $entry) {
    $nowdate = split("/", $entry[1]);
    $ourDate =
mktime(0,0,0,(int)$nowdate[0],(int)$nowdate[1],(int)$nowdate[2]);
    $ourMonth = date("M", $ourDate);
    $ourDay     = date("D", $ourDate);
    $ourYear = date("o", $ourDate);
    $firstDayOfMonth = mktime(0,0,0, $nowdate[0], 1 , $nowdate[2]);
    $firstDayInMonth = date("D", $firstDayOfMonth);
    $daysInMonth = date("d", mktime(0,0,0,(int)($nowdate[0]+1), 0,
(int)$nowdate[2]));
    $day_of_week = $firstDayInMonth;
                                                                
    switch($day_of_week) {
        case "Sun": $blank = 0; break;
        case "Mon": $blank = 1; break;
        case "Tue": $blank = 2; break;
        case "Wed": $blank = 3; break;
        case "Thu": $blank = 4; break;
        case "Fri": $blank = 5; break;
        case "Sat": $blank = 6; break;
    }
                                
    if(isset($currentMonth) && $ourMonth != $currentMonth) {
        $currentMonth = $ourMonth;
                        
        $this->startCalendarMonth($ourMonth, $ourYear);
                
        $day_count = $this->shootBlanks($blank);
                
        for($day_num = 1; $day_num <= $daysInMonth; $day_num++)
        {                                                       
            echo "<td>$day_num</td>";
            $day_count++;
            if($day_count > 7) {
                echo "</tr>\n    <tr>";
                $day_count = 1;
            }
        }
        $this->endCalendar();
    }


Expected result:
----------------
The expected result is that November 2008 would return 30 days and
December 2008 return 31 days.  

Actual result:
--------------
The current result is Nov 2008 returns 29 days and December 2008
returns 31.  Clearly the problem is with November.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46861&edit=1

Reply via email to