xxxxxxxxxx
$currentDateTime = new DateTime();
$currentDateTime->add(new DateInterval('P1D'));
$newDateTime = $currentDateTime->format('Y-m-d H:i:s');
echo $newDateTime;
xxxxxxxxxx
<?php
$date = "2022-08-12";
// Add days to date and display it
echo date('Y-m-d', strtotime($date. ' +10 days')); // 2022-08-22
echo date('Y-m-d', strtotime(date('Y-m-d'). ' +1 days')); // 2022-08-23
echo date('Y-m-d', strtotime(date('Y-m-d'). ' +1 months')); // 2022-09-12
echo date('Y-m-d', strtotime(date('Y-m-d'). ' +1 year')); // 2023-08-12
?>
xxxxxxxxxx
$start_date = "2015/03/02";
$date = strtotime($start_date);
$date = strtotime("+7 day", $date);
echo date('Y/m/d', $date);
xxxxxxxxxx
<?php
// adding extra days to date
// Steps:
// 1) using carbon
// 2) using strtotime
//Step 1
$date = date('Y M d h:i:s') // 2020 09 22 22:09:26 UTC
$new_date = Carbon::parse($date->addDays(1); // adds extra day
// Step 2
$date = date('Y M d h:i:s') // 2020 09 22 22:09:26 UTC
echo $new_date = date('Y M d h:i:s', strtotime($date. '+1 day'));
?>
xxxxxxxxxx
// add 1 day to the date above
$n = date('Y-m-d', strtotime( $d . " +1 days"));
xxxxxxxxxx
$date = '2021-11-01'; // Replace with your desired date
$newDate = date('Y-m-d', strtotime($date.' +1 day'));
echo $newDate;
xxxxxxxxxx
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P1D'));
xxxxxxxxxx
<?php
$date = new DateTime('2016-06-06'); // Y-m-d
$date->add(new DateInterval('P30D'));
echo $date->format('Y-m-d') . "\n";
?>