From: hlegius at gmail dot com Operating system: Linux PHP version: 5.2.10 PHP Bug Type: Date/time related Bug description: strtotime and mktime
Description: ------------ I expected the last day of given timestamp, but when mktime is the second argument of strtotime this do not happens. So, I need save mktime's result in a variable to use it later in strtotime Reproduce code: --------------- <?php // FAIL ! $timestamp = time(); for ($i = 0; $i<10; $i++) { $timestamp = strtotime('yesterday', mktime(0,0,0, (date('n', $timestamp) + 1), 1, date('Y'))); var_dump(date('d/m/Y', $timestamp)); } ?> <?php // It's works ! $timestamp = time(); for ($i = 0; $i<10; $i++) { $timestamp = mktime(0,0,0, (date('n', $timestamp) + 1), 1, date('Y')); var_dump(date('d/m/Y', strtotime('yesterday', $timestamp))); // here, we have a $timestamp } ?> Expected result: ---------------- string '30/06/2009' (length=10) string '31/07/2009' (length=10) string '31/08/2009' (length=10) string '30/09/2009' (length=10) string '31/10/2009' (length=10) string '30/11/2009' (length=10) string '31/12/2009' (length=10) string '31/01/2009' (length=10) string '28/02/2009' (length=10) string '31/03/2009' (length=10) Actual result: -------------- Output of first Code: string '30/06/2009' (length=10) string '30/06/2009' (length=10) string '30/06/2009' (length=10) string '30/06/2009' (length=10) string '30/06/2009' (length=10) string '30/06/2009' (length=10) string '30/06/2009' (length=10) string '30/06/2009' (length=10) string '30/06/2009' (length=10) string '30/06/2009' (length=10) Output of second code: string '30/06/2009' (length=10) string '31/07/2009' (length=10) string '31/08/2009' (length=10) string '30/09/2009' (length=10) string '31/10/2009' (length=10) string '30/11/2009' (length=10) string '31/12/2009' (length=10) string '31/01/2009' (length=10) string '28/02/2009' (length=10) string '31/03/2009' (length=10) -- Edit bug report at http://bugs.php.net/?id=48698&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48698&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48698&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48698&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48698&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48698&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48698&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48698&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48698&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48698&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48698&r=support Expected behavior: http://bugs.php.net/fix.php?id=48698&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48698&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48698&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48698&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48698&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48698&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48698&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48698&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48698&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48698&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48698&r=mysqlcfg