From:             
Operating system: Centos5 64bit
PHP version:      Irrelevant
Package:          Date/time related
Bug Type:         Bug
Bug description:Date not rolling back one month

Description:
------------
Howdy,



This is a php implementation on a cpanel box:

PHP 5.2.9 (cli) (built: Jun  5 2009 04:19:37) 

Copyright (c) 1997-2009 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

    with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by
eAccelerator

    with the ionCube PHP Loader v3.3.20, Copyright (c) 2002-2010, by
ionCube Ltd., and

    with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend
Technologies

    with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH

    with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend
Technologies





Today is 2010 - 10 - % and basically I have the following:



$thisMonth = date("Y-m-1");

this will return as expected: 2010-10-1



Then I have this:

$lastmonth = strftime("%Y-%m-1", strtotime("-1 months"));

Which does not return as expected, it returns: 2010-10-1 the same as
above.

Expected result would be: 2010-09-1

However I have tried alternative approaches such as naming.

$lastmonth = strftime("%Y-%m-1", strtotime("-1 month"));

Same thing.



Possible bug?

Test script:
---------------
<?php





echo date("Y-m-1"); //Returns 2010-10-1



echo "<br />";



echo strftime("%Y-%m-1", strtotime("-2 month")); // Returns 2010-08-1



echo "<br />";



echo strftime("%Y-%m-1", strtotime("-1 month")); // Unexpected: 2010-10-1



echo "<br />"; 



echo strftime("%Y-%m-1", strtotime("-1 months")); // Unexpected: 2010-10-1



?>

Expected result:
----------------
I expect that it would return a back roll of on month from the current



At the moment of posting this it is october, so it should roll to
september, delivering results:



2010-09-1





Actual result:
--------------
Well at the moment it is just returning the current month:



2010-10-1





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

Reply via email to