|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-01-31 16:20 UTC] gavinp at tbs dot uk dot com
Description:
------------
Hi derick@php.net,
I have not posted this twice,(however because you locked the last bug I now have to and in case another user has ... your search system will need some work then. I could not find a bug describing the same problem. Please direct me to the correct place that is an open bug and I will happy tag this onto the end of it.
strtotime('next month', $basedate); where $basedate = today.
Should output the next month. The next month from today is Feb. Simple. That is the 'expected behaviour'.
That's like saying 2+2 = 4 except on Fridays when it = 5, and then saying because it's always been like this then it's 'Expected.'
If you are going to refer me to the documentation, please direct me to the documentations excact location where it says 'next month on the last day of the month should be two months instead of one.' I can not find this part in the documentation anywhere also.
However I would love to eat humble pie so please do show me.
Reproduce code:
---------------
$basedate = time();
$date1 = strtotime('next month', $basedate);
$date2 = strtotime('+1 month', $basedate);
$date3 = strtotime('first month', $basedate);
$date4 = mktime(0, 0, 0, date("m")+1, date("d"), date("Y"));
$format1 = date('F', $date1);
$format2 = date('F', $date2);
$format3 = date('F', $date3);
$format4 = date('F', $date4);
echo $format1;
echo $format2;
echo $format3;
echo $format4;
Expected result:
----------------
February
February
February
February
Actual result:
--------------
March
March
March
March
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 05:00:01 2025 UTC |
Excatly. Hence why it's a bug. I'm asking PHP to add 1 to the month number. Not to add 31 days to the month. strtotime('next month', $basedate); where $basedate = today The expected result would be to produce the next month, not to add 31 days and provide the month, which may, or may not be, the next month.