Req #61962 [Asn->Csd]: Relative format : second/third... not parsed

From: Date: Fri, 13 May 2022 13:39:58 +0000
Subject: Req #61962 [Asn->Csd]: Relative format : second/third... not parsed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241491@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61962&edit=1 ID: 61962 Updated by: derick@php.net Reported by: francois dot dambrine at isen-lille dot fr Summary: Relative format : second/third... not parsed -Status: Assigned +Status: Closed Type: Feature/Change Request Package: Date/time related Operating System: Ubuntu 11.10 PHP Version: 5.4.2 Assigned To: heiglandreas Block user comment: N Private report: N New Comment: I am closing this, as this would increase the parser complexity significantly, with a reasonable workaround available. If you have a really compelling case, feel free to add a ticket to https://github.com/php/php-src/issues, but it needs to have a really good reason for this to get added. Previous Comments: ------------------------------------------------------------------------ [2016-06-14 11:41:11] cmb@php.net > This is just not implemented. So I'm changing to feature request. ------------------------------------------------------------------------ [2012-05-11 16:38:25] derick@php.net This is just not implemented. For you now, you'll have to do: $firstDay = new DateTime('first day of previous month'); $firstDay->modify( 'next day' ); ------------------------------------------------------------------------ [2012-05-11 15:47:33] zhanglijiu at gmail dot com There is no parameter 'second,third day of previous month'. ------------------------------------------------------------------------ [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

« previous php.bugs (#241491) next »