Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Increment PHP Months
$nextMonthDate = $date->copy();
$nextMonthDate->addMonths($addMonths);
// j - Day of the month without leading zeros
if ($nextMonthDate->format('j') != $date->format('j'))
{
$date->modify('last day of +'.$addMonths.' months');
}
else
{
$date->addMonths($addMonths);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment