Answers for "how to add time in date function in php"

PHP
1

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"));
Posted by: Guest on April-03-2020
1

add 1 day php datetime

$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P1D'));
Posted by: Guest on November-04-2020

Code answers related to "how to add time in date function in php"

Browse Popular Code Answers by Language