I want to get the last day of the month of the next year from a given date
Here is how I did :
$copy = new \DateTime();
$lastDay = new \DateTime($copy->add((new \DateInterval('P1Y')))->format('Y-m-t'));
This works exept in this exemple :
$copy = new \DateTime('2024-02-29');
$lastDay = new \DateTime($copy->add((new \DateInterval('P1Y')))->format('Y-m-t'));
It returns me '2025-03-31' while I want '2025-02-28'
Here is the solution :
Thanks to shingo