Edit report at http://bugs.php.net/bug.php?id=53741&edit=1
ID: 53741 Updated by: [email protected] Reported by: metwo at gmx dot net Summary: DateTime, date_create, strtotime - wrong result on realtive date time string Status: Bogus Type: Bug Package: Date/time related Operating System: inux 2.6.36.3 x86_64 PHP Version: 5.2.17 Block user comment: N Private report: N New Comment: And it's not a bug either. "midnight", "first day" and "last month" are all separate items. 2011-01-13 17:23 "midnight" resets the time to 00:00: 2011-01-13 00:00 "first day" adds a day: 2011-01-14 00:00 "last month" removes a month: 2011-12-14 00:00 In PHP 5.3 you can do: "midnight first day of last month" where "midnight", "first day of" and "last month" are the tokens: 2011-01-13 17:23 "midnight" resets the time to 00:00: 2011-01-13 00:00 "last month" removes a month: 2011-12-14 00:00 "first day of" resets day to 1: 2011-12-01 00:00 Previous Comments: ------------------------------------------------------------------------ [2011-01-14 04:47:44] [email protected] 5.2 is no longer supported. ------------------------------------------------------------------------ [2011-01-13 17:24:56] metwo at gmx dot net Description: ------------ parsing of relative date/time string "midnight first day last month" returns a wrong result in php 5.2.17 Test script: --------------- <?php print_r(date_create('midnight first day last month')); print $d->format('Y-m-d H:i:s') . "\n"; print date('Y-m-d H:i:s', strtotime('midnight first day last month')); Expected result: ---------------- // relative to current date/time - 2011-01-13 17:23 DateTime Object ( [date] => 2010-12-01 00:00:00 [timezone_type] => 3 [timezone] => Europe/Berlin ) 2010-12-01 00:00:00 2010-12-01 00:00:00 Actual result: -------------- // relative to current date/time - 2011-01-13 17:23 DateTime Object ( ) 2010-12-14 00:00:00 2010-12-14 00:00:00 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53741&edit=1
