Answers for "Adding or Subtracting Time"

PHP
2

Adding or Subtracting Time

$dateTime = new DateTime('2016-01-01');
$dateTime->modify('+1 day');
echo $dateTime->format('Y-m-d H:i:s');`
# Output: 2016-01-02 00:00:00

# You can as well use the constructor if you work on the current date:



$dateTime = new DateTime('+1d');
echo $dateTime->format('Y-m-d H:i:s');`
# Output the current date plus one day.
Posted by: Guest on February-24-2021

Browse Popular Code Answers by Language