Edit report at https://bugs.php.net/bug.php?id=60654&edit=1
ID: 60654 User updated by: keloran at develbox dot info Reported by: keloran at develbox dot info Summary: Strtotime taking leap year into effect before the leap Status: Not a bug Type: Bug Package: Date/time related Operating System: Gentoo PHP Version: 5.4SVN-2012-01-04 (SVN) Block user comment: N Private report: N New Comment: <?php $preData = 1327928400; $a = strtotime("last monday", $preDate); $b = strtotime("last year last monday", $a); $c = date("d/m/Y H:i:s", $a); $d = date("d/m/Y H:i:s", $b); print_r(array( "PreDate" => $preDate, "Today Time" => $a, "Last Year Time" => $b, "Converted Today" => $c, "Converted Last Year" => $d, )); Previous Comments: ------------------------------------------------------------------------ [2012-01-30 23:00:57] ras...@php.net Keloran, your bug report is confusing with respect to day/month order. I am assuming you mean m/d when you say 02/01 and 03/01 but your script says d/m/Y. Please provide an actual script with a timestamp baked in. Like this: echo date("d/m/Y H:i:s\n",1328126500); echo date("d/m/Y\n", strtotime("yesterday last year",1328126500)); That outputs: 01/02/2012 12:01:40 31/01/2011 which looks completely correct to me. Austin, yours is not a bug. When you add a month to Jan.30 it goes to Feb.30 which doesn't exist. So it adjusts it to Mar.1. strtotime follows the standard UNIX date addition behaviour in this. From your Linux command line try this: % date Mon Jan 30 17:49:22 EST 2012 % date --date='+1 month' +'Next month is %B' Next month is March You can find this behaviour documented here: http://www.gnu.org/software/tar/manual/html_node/Relative-items-in-date- strings.html#SEC125 ------------------------------------------------------------------------ [2012-01-30 20:34:16] austin dot w dot best at gmail dot com To add to this... date('n', strtotime('+ 1 month', time())); That should be 2 and it is returning a 3. Now it is 3:30 PM EST when i noticed this, so by using a preset timestamp you can reproduce this. date('n', strtotime('+ 1 month', '1327954976')); Will return 3 instead of 2 as well. I am guessing this will never be fixed, and if not, maybe say "hey, we cant fix this one" -OR "this is more work to fix than it is worth" instead of ignoring the problem? https://bugs.php.net/bug.php?id=27793 that is from 2004!!! Not to mention there is a note at the bottom of it that it was posted at least 5 other times. ------------------------------------------------------------------------ [2012-01-04 13:51:41] keloran at develbox dot info Description: ------------ If you do the test, you should get if today is 02/01/2012 the result should be 03/01/2011 but instead you get 02/01/2011 Test script: --------------- echo date("d/m/Y", strtotime("yesterday last year")); Expected result: ---------------- 03/01/2011 Actual result: -------------- 02/01/2011 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60654&edit=1