date ('dmY', strtotime ('10 .08.2010 ') + 667 * 86400);
It works incorrectly gives the answer 07.06.2012 and should be 03.08.2012
It is possible through the well-known library Carbon
use Carbon\Carbon; // К указанной дате добавить год и вывести в формате даты echo Carbon::parse('10.08.2010')->addYears(1)->toDateString(); It is very flexible, you can add through the methods:
->addHours() // Часы ->addDays() // Дни ->addYears() // Года // и т.д. If you take into account the figures that you gave, you can do this:
$date = new DateTime('10.08.2010'); $date->add(new DateInterval('P1Y359D')); echo $date->format('dmY'); The result will be the required date.
03.08.2012 After discussion with @ Enikeyschik decided to add a couple of points. My calculations, as you could understand, are repelled from the date of 10.08.2010 and are completed on the date indicated at the end of the post on 03.08.2012.
Another moment. Unfortunately, the author did not specify: this is a specific date or there is a certain array with different dates for which the calculation takes place. In the latter case, the approach to the formation of the result based on the number of days + the original date is fundamentally wrong, because there may be 366 days in a year. In this case, in my opinion, it is necessary to add "2 years" and subtract 6 days from here.
Source: https://ru.stackoverflow.com/questions/812428/
All Articles
86400is a day, that is, a day. - Vismanstrtotime('+3 days');- And