How can I calculate End date automatically in Php ? When I enter current date it will be auto calculate 16moths or 480days. duration between current and end date 16month and days.
CodePudding user response:
<?php
$Date = "2021-09-27";
echo date('Y-m-d', strtotime($Date. ' 480 days'));
?>
CodePudding user response:
try this solution:
$currentDate = date('Y-m-d');
$endDate = date('Y-m-d', strtotime($currentDate. ' 480 days'));
echo $currentDate;
echo '<br>';
echo $endDate;
CodePudding user response:
here is the solution
$time = new DateTime(date('Y:m:d H:i:s'));
$time->add(new DateInterval('P10D'));
echo $endtime = $time->format('Y:m:d H:i:s');
for more info visit: https://www.php.net/manual/en/datetime.add.php