#51096 [Opn->Bgs]: strtotime returns wrong results

From: Date: Sat, 20 Feb 2010 15:22:06 +0000
Subject: #51096 [Opn->Bgs]: strtotime returns wrong results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-147891@lists.php.net to get a copy of this message
ID: 51096 Updated by: derick@php.net Reported By: phpbugs at rizzt dot kicks-ass dot org -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: linux PHP Version: 5.2.12 New Comment: That's because those things were introduced in PHP 5.3: derick@kossu:~$ pe 5.2dev derick@kossu:~$ php <?php echo strftime('1 %Y/%m/%d')."\n"; echo strftime('2 %Y/%m/%d', strtotime('first day'))."\n"; echo strftime('3 %Y/%m/%d', strtotime('last day'))."\n"; echo strftime('4 %Y/%m/%d', strtotime('next month'))."\n"; echo strftime('5 %Y/%m/%d', strtotime('first day next month'))."\n"; echo strftime('6 %Y/%m/%d', strtotime('last day next month'))."\n"; ?> 1 2010/02/20 2 2010/02/21 3 2010/02/19 4 2010/03/20 5 2010/03/21 6 2010/03/19 derick@kossu:~$ pe 5.3dev derick@kossu:~$ php <?php echo strftime('1 %Y/%m/%d')."\n"; echo strftime('2 %Y/%m/%d', strtotime('first day'))."\n"; echo strftime('3 %Y/%m/%d', strtotime('last day'))."\n"; echo strftime('4 %Y/%m/%d', strtotime('next month'))."\n"; echo strftime('5 %Y/%m/%d', strtotime('first day next month'))."\n"; echo strftime('6 %Y/%m/%d', strtotime('last day next month'))."\n"; ?> 1 2010/02/20 2 2010/02/01 3 2010/02/28 4 2010/03/20 5 2010/03/01 6 2010/03/31 Previous Comments: ------------------------------------------------------------------------ [2010-02-20 15:20:45] phpbugs at rizzt dot kicks-ass dot org Sorry, I forgot to change 2 & 3 Expected result: ---------------- 1 2010/02/20 2 2010/02/01 3 2010/02/28 4 2010/03/20 5 2010/03/01 6 2010/03/31 ------------------------------------------------------------------------ [2010-02-20 15:18:08] phpbugs at rizzt dot kicks-ass dot org Description: ------------ strtotime with "first day next month" or "last day next month" does not work Reproduce code: --------------- echo strftime('1 %Y/%m/%d')."\n"; echo strftime('2 %Y/%m/%d', strtotime('first day'))."\n"; echo strftime('3 %Y/%m/%d', strtotime('last day'))."\n"; echo strftime('4 %Y/%m/%d', strtotime('next month'))."\n"; echo strftime('5 %Y/%m/%d', strtotime('first day next month'))."\n"; echo strftime('6 %Y/%m/%d', strtotime('last day next month'))."\n"; Expected result: ---------------- 1 2010/02/20 2 2010/02/21 3 2010/02/19 4 2010/03/20 5 2010/03/01 6 2010/03/31 Actual result: -------------- 1 2010/02/20 2 2010/02/21 3 2010/02/19 4 2010/03/20 5 2010/03/21 6 2010/03/19 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=51096&edit=1

« previous php.bugs (#147891) next »