php add 1 day to current date
There are many methods to add days to $Date. The smart way to add days to $Date is using built-in functions like strtotime(), date_add() in PHP.
1 Using strtotime() Function:
We use the strtotime() Function to change an English textual date-time style into a UNIX timestamp.
The two parameters accepted by this function are described here.
The $EnglishDateTime identify the English textual date-time representation, which describes the date or time to be restored.
Output:
2019-05-20
php add days to date
$start_date = "2015/03/02";
$date = strtotime($start_date);
$date = strtotime("+7 day", $date);
echo date('Y/m/d', $date);
php date strtotime add days
// add 1 day to the date above
$n = date('Y-m-d', strtotime( $d . " +1 days"));
// add 1 month to the date above
$n = date('Y-m-d', strtotime( $d . " +1 month"));
// add 1 year to the date above
$n = date('Y-m-d', strtotime( $d . " +1 year"));
// subtract 1 day to the date above
$n = date('Y-m-d', strtotime( $d . " -1 days"));
// subtract 1 month to the date above
$n = date('Y-m-d', strtotime( $d . " -1 month"));
// subtract 1 year to the date above
$n = date('Y-m-d', strtotime( $d . " -1 year"));
add 1 day php datetime
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P1D'));
PHP add 1 day to current date
echo date('j F, Y',strtotime("+1 days"));
php strtotime plus 1 day
$NewDate = date('Y-m-d', strtotime('+7 days'));
2 Using date_add() Function:
This function is used to add days, years, months, hours, seconds, and minutes.
There are two methods accepted by this function.
Object:
This parameter identifies the DateTime article restored by date_create() function.
Interval:
This parameter describes the object of DateInterval.
Output:
2019-05-20