Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding one day to a date

Tags:

date

php

datetime

People also ask

How can I add 1 day to current date?

const date = new Date(); date. setDate(date. getDate() + 1); // ✅ 1 Day added console.

How can I get tomorrow date in dd mm yyyy format in Java?

get(Calendar. DAY_OF_MONTH) + 1; will it display tomorrow's date. or just add one to today's date? For example, if today is January 31.


<?php
$stop_date = '2009-09-30 20:24:00';
echo 'date before day adding: ' . $stop_date; 
$stop_date = date('Y-m-d H:i:s', strtotime($stop_date . ' +1 day'));
echo 'date after adding 1 day: ' . $stop_date;
?>

For PHP 5.2.0+, you may also do as follows:

$stop_date = new DateTime('2009-09-30 20:24:00');
echo 'date before day adding: ' . $stop_date->format('Y-m-d H:i:s'); 
$stop_date->modify('+1 day');
echo 'date after adding 1 day: ' . $stop_date->format('Y-m-d H:i:s');

$date = new DateTime('2000-12-31');

$date->modify('+1 day');
echo $date->format('Y-m-d') . "\n";

It Worked for me: For Current Date

$date = date('Y-m-d', strtotime("+1 day"));

for anydate:

date('Y-m-d', strtotime("+1 day", strtotime($date)));

Simplest solution:

$date = new DateTime('+1 day');
echo $date->format('Y-m-d H:i:s');

Try this

echo date('Y-m-d H:i:s',date(strtotime("+1 day", strtotime("2009-09-30 20:24:00"))));