Reputation: 151
Hi currently I have a date that is printing the last day of the month for example this month is August, it will print August 31, 2017.
This is the code:
$lastdate = date('F t, Y');
echo $lastdate ;
My problem is I want it to print 5 additional days to the last day of the month, so for example rather than it will print August 31, 2017 it will print Septermber 5, 2017
Upvotes: 0
Views: 73
Reputation: 219814
echo (new \DateTime('last day of this month'))->modify('+5 days')->format('F j, Y');
To do next month:
echo (new \DateTime('last day of next month'))->modify('+5 days')->format('F j, Y');
To do another month:
echo (new \DateTime('October 31, 2017'))->modify('+5 days')->format('F j, Y');
That should give you the idea.
Upvotes: 3