Edit report at https://bugs.php.net/bug.php?id=61962&edit=1
ID: 61962 Comment by: zhanglijiu at gmail dot com Reported by: francois dot dambrine at isen-lille dot fr Summary: Relative format : second/third... not parsed Status: Open Type: Bug Package: Date/time related Operating System: Ubuntu 11.10 PHP Version: 5.4.2 Block user comment: N Private report: N New Comment: There is no parameter 'second,third day of previous month'. Previous Comments: ------------------------------------------------------------------------ [2012-05-06 11:30:46] francois dot dambrine at isen-lille dot fr Description: ------------ As I was testing a script where I need to get the second day of previous month I found out this issue : I can't get this day with that phrase. With larger tests I got the issue for every "ordinal" keyword apart from "first" and "last". Test script: --------------- date_default_timezone_set('Europe/Paris'); $firstDay = new DateTime('first day of previous month'); echo $firstDay->format('l').PHP_EOL; $lastDay = new DateTime('last day of previous month'); echo $lastDay->format('l').PHP_EOL; $secondDay = new DateTime('second day of previous month'); echo $secondDay->format('l').PHP_EOL; $thirdDay = new DateTime('third day of previous month'); echo $thirdDay->format('l').PHP_EOL; Expected result: ---------------- Sunday Monday Monday Tuesday Actual result: -------------- Sunday Monday PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (second day of previous month) at position 11 (o): The timezone could not be found in the database' in /home/isen/essai.php:7 Stack trace: #0 /home/isen/essai.php(7): DateTime->__construct('second day of p...') #1 {main} thrown in /home/isen/essai.php on line 7 Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (second day of previous month) at position 11 (o): The timezone could not be found in the database' in /home/isen/essai.php:7 Stack trace: #0 /home/isen/essai.php(7): DateTime->__construct('second day of p...') #1 {main} thrown in /home/isen/essai.php on line 7 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61962&edit=1