Req #51188 [Opn->Nab]: strtotime - last dayofweek of the month feature request
| From: | heiglandreas@php.net | Date: | Thu, 12 Jan 2017 20:53:12 +0000 |
| Subject: | Req #51188 [Opn->Nab]: strtotime - last dayofweek of the month feature request | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206582@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=51188&edit=1
ID: 51188
Updated by: heiglandreas@php.net
Reported by: kbush at workforcerx dot org
Summary: strtotime - last dayofweek of the month feature
request
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: Date/time related
Operating System: Windows 2003
PHP Version: 5.2.13
Block user comment: N
Private report: N
New Comment:
"in" does not work (as you can see from https://github.com/heiglandreas/php-src/blob/master/ext/date/lib/parse_date.re#L938.
And as the "of" is mandatory appending a month to a valid "lastMonday"
doesn't change the month. Therefore the "last Monday April" returns the last Monday
calculated from the given datetime.
All other versions do work as you can see in https://3v4l.org/qQVC0
Previous Comments:
------------------------------------------------------------------------
[2010-03-03 00:58:46] kbush at workforcerx dot org
Description:
------------
I was attempting to strtotime to find the last (specific) day of the month.
Example: Last Monday of May
But it returns false. I ended up taking a different approach but this would have
been a nice feature.
Also tried: Last Monday April
Which did not return the results I was expecting.
Maybe we can get a little more documentation on this function and what terms it
accepts? (If this exists, I was unable to find it)
Test script:
---------------
$f = "Y-m-d";$now = 1267571715; // 2010-03-02
echo "<pre>";
echo date($f, strtotime("last Monday",$now))."\n";
echo date($f, strtotime("last Monday in March",$now))."\n";
echo date($f, strtotime("last Monday of March",$now))."\n";
echo date($f, strtotime("last Monday April",$now))."\n";
echo date($f, strtotime("last Monday in April",$now))."\n";
echo date($f, strtotime("last Monday of April",$now))."\n";
echo "</pre>";
Expected result:
----------------
2010-03-01
2010-03-29
2010-03-29
2010-04-26
2010-04-26
2010-04-26
Actual result:
--------------
2010-03-01 (ok)
1969-12-31 (nothing returned)
1969-12-31 (nothing returned)
2010-03-29 (unexpected, but valid)
1969-12-31 (nothing returned)
1969-12-31 (nothing returned)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=51188&edit=1