Bug #71725 [Csd->Nab]: Incorrect ordinal suffix used for 29th February
| From: | requinix@php.net | Date: | Mon, 07 Mar 2016 01:11:33 +0000 |
| Subject: | Bug #71725 [Csd->Nab]: Incorrect ordinal suffix used for 29th February | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-199635@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71725&edit=1
ID: 71725
Updated by: requinix@php.net
Reported by: daniel at honestempire dot com
Summary: Incorrect ordinal suffix used for 29th February
-Status: Closed
+Status: Not a bug
Type: Bug
-Package: Calendar related
+Package: Date/time related
Operating System: Mac OS X
PHP Version: 7.0.4
Block user comment: N
Private report: N
New Comment:
'S' works according to the date you passed, which was Feb 1. 't' is merely the
number of days in the month and will not magically turn the date into Feb 29.
// 03-00 will underflow to whichever is the last day of February
$lastDayOfMonth = date('jS F Y', strtotime('2016-03-00 12:00:00'));
Previous Comments:
------------------------------------------------------------------------
[2016-03-06 22:46:07] daniel at honestempire dot com
It would appear the ordinal is parsed before the t flag, removing the ordinal fixes my issue.
------------------------------------------------------------------------
[2016-03-06 22:27:17] daniel at honestempire dot com
Description:
------------
When attempting to find the last weekday of February 2016, I stumbled across this bug. See the test
script for replication information.
Test script:
---------------
$lastDayOfMonth = date('tS F Y', strtotime('2016-02-01 12:00:00'));
var_dump($lastDayOfMonth); // string(18) "29st February 2016"
var_dump(date('d', strtotime(sprintf('last weekday %s', $lastDayOfMonth)))); //
string(2) "26" (should be string(2) "29")
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71725&edit=1