From:             john at designingforbusiness dot com
Operating system: OS X, Ubantu
PHP version:      5.2.8
PHP Bug Type:     *General Issues
Bug description:  mktime returns the wrong number of days for November.

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 bug report at http://bugs.php.net/?id=46861&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46861&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46861&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46861&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46861&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46861&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46861&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46861&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46861&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46861&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46861&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46861&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46861&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46861&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46861&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46861&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46861&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46861&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46861&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46861&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46861&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46861&r=mysqlcfg

Reply via email to