Here's a cleaning test that does not expire:
<?php $origin = mktime(18, 0, 0, 7, 31, 2015); var_dump( date('r', $origin), date('r', strtotime('-1 months', $origin)) );
string(31) "Fri, 31 Jul 2015 18:00:00 +0200" string(31) "Wed, 01 Jul 2015 18:00:00 +0200"
I am sure that this is a problem with the documentation, because the manual clearly states this (primary focus):
The relative values of the month are calculated depending on the length of the months that they pass. An example is "+2 month 2011-11-30", which will produce "2012-01-30". This is due to November 30 days in length, and December - 31 days in length, just 61 days.
... and this is wrong.
PHP Error Tracking The tone is deceiving it. They are all closed, if not a mistake. Here is the corresponding comment from 2009 that explains this:
I agree that this is annoying behavior.
In addition, implementation is problematic. Basically , if you use '+1 month', it takes a month, adds 1 and analyzes the result as a new date .
If you use “+1 month” in the first month of the month, it sets the date in the next first month.
This behavior gives the impression that php takes into account the length of the month, which is incorrect.
But if you use "+1 month" on the last day of the month, the result is unexpected , since 2009-05-31 becomes 2009-06-31, which is an invalid date and then interpreted as 2009-07-01.
This should at least be mentioned in the documentation .