php add days to date
<?php
// PHP program to add days to $Date
// Declare a date
$date = "2019-05-10";
// Add days to date and display it
echo date('Y-m-d', strtotime($date. ' + 10 days'));
?>
4.67
3
$date = new DateTime('2020-11-24');
$date->add(new DateInterval("P9D"));
echo $date->format('Y-m-d');
Thank you!
3
0
4.25
4
$date = "Mar 03, 2011";
$date = strtotime($date);
$date = strtotime("+7 day", $date);
echo date('M d, Y', $date);
Thank you!
4
0
3.67
3
$start_date = "2015/03/02";
$date = strtotime($start_date);
$date = strtotime("+7 day", $date);
echo date('Y/m/d', $date);
Thank you!
3
0
3.9
10
<?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'));
?>
Thank you!
10
0
4.67
6
$created_at=date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s") . ' +1 day'));
Thank you!
6
0
Are there any code examples left?
New code examples in category PHP