Wednesday, 1 October 2014

Get tomorrows date from date in PHP

<?php

//answer1

$datetime = new DateTime('tomorrow');
echo $datetime->format('Y-m-d H:i:s');


//answer2
$datetime = new DateTime('2013-10-02');
$datetime->modify('+1 day');
echo $datetime->format('Y-m-d H:i:s');


//answer3

$datetime = new DateTime('2013-10-02');
$datetime->add(new DateInterval("P1D"));
echo $datetime->format('Y-m-d H:i:s');


//answer4

echo (new DateTime('2013-10-02'))->add(new DateInterval("P1D"))->format('Y-m-d H:i:s');
                               
$tomorrow_timestamp = strtotime('+1 day', strtotime('2013-10-02'));


echo $tomorrow;



//answer5
//1 Day = 24*60*60 = 86400
echo date("d-m-Y", time()+86400);
?>


<?php

//You could also use the DateTime class. today as 10/01

$date = new DateTime('tomorrow');

echo $date->format('m/d/Y'); # 10/01/2013
//To set the time.

$date->setTime(12, 0 ,0);

echo $date->format('m/d/Y H:i:s'); # 10/02/2013 12:00:00
//In your case.

echo $date->format('l jS F');






echo date('l jS F', strtotime("+1 day"));


$date = date("l jS F", strtotime("tomorrow"));
echo $date;  

?>

0 comments:

Post a Comment