note 105784 modified in datetime.formats.relative by danbrown
| From: | danbrown@php.net | Date: | Wed, 14 Sep 2011 21:38:26 +0000 |
| Subject: | note 105784 modified in datetime.formats.relative by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183173@lists.php.net to get a copy of this message | ||
If the ordinal being used is "last" and the next month is n, use the "n 1".
Otherwise, if the previous month is p and it has d number of days in it, use "p d".
For example: "last thursday of November" becomes "last thursday December 1" and
"fourth thursday of November" becomes "fourth thursday September 30th"
Hopes this helps someone out there.
--was--
My previous note was incorrect in a few cases. I apologize for not testing this thoroughly. It seems
as if replacing "of" with '1st' is not good enough and, actually, the right
(possibly only better) way to go about it is a little bit more complex. What actually needs to be
done is the following:
If the ordinal being used is "last" and the next month is n, use the "n 1".
Otherwise, if the previous month is p and it has d number of days in it, use "p d".
For example: "last thursday of November" becomes "last thursday December 1" and
"fourth thursday of November" becomes "fourth thursday September 30th"
Hopes this helps someone out there.
http://php.net/manual/en/datetime.formats.relative.php