From:             rob at guidamedia dot com
Operating system: iis
PHP version:      5.2.9
PHP Bug Type:     Scripting Engine problem
Bug description:  Sttotime returning wrong dates

Description:
------------
When converting weeks and days to a date using strtotime, some months
return the wrong dates. For instance, strtotime("first thursday",
mktime(0,0,0,11,1,2009)) returns 11/4/2009, which is a wednesday. There are
also issues using "last".

This seems to be happening with November 2009. I am not sure about other
years or other months. I think I had issues there as well, but
infrequently. I tried seeing if the issue is with any month when the first
day of the month is sunday, but it does not appear to be the case.

I am creating a new function to handle strtotime in this manner, because I
found more issues with using this function and creating a series of dates
that are incremented by a year.


Reproduce code:
---------------
public function getDateFromWeekAndDayOfMonth($d, $m, $y){
$fistDayOfMonth = mktime(0, 0, 0, $m, 1, $y)
$firstWeekForDay = strtotime("first " . $d, $fistDayOfMonth);
return $firstWeekForDay;
}


Expected result:
----------------
For the First Thursday in November 1, 2009, I expect to have the datetime
for 11-5-2009.

Actual result:
--------------
11-4-2009

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

Reply via email to