From:             
Operating system: Ubuntu 11.10
PHP version:      5.4.2
Package:          Date/time related
Bug Type:         Bug
Bug description:Relative format : second/third... not parsed

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 bug report at https://bugs.php.net/bug.php?id=61962&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=61962&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=61962&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=61962&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=61962&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=61962&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=61962&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=61962&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=61962&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=61962&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=61962&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=61962&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=61962&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=61962&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=61962&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=61962&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=61962&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=61962&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=61962&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=61962&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=61962&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=61962&r=mysqlcfg

Reply via email to