In my code I am successful to display current date but my requirement is to show next day date after 3
hours e.g. 2017-08-17 20:00:00
the next date will be 2017-08-18
but it will show next date after spending 3 hours i.e. 2017-08-18 03:00:00
until that it remain show the old date.
I am able to add 3
hours to current date/time but I don't know how to show it after 3rd hour of the next date. Here is my code
<?php
date_default_timezone_set('Asia/Kolkata');
$time_add = date("Y-m-d H:i:s", strtotime('+3 hours'));
$time_now = date("Y-m-d H:i:s");
echo $time_now;
?>
echo date("Y-m-d H:i:s", strtotime('+3 hours'));
The problem with your code is that you were assigning this to a variable called $time_add
but then doing nothing with it.
If you want to print the current date/time after it, just use it without +3 hours
:
echo date("Y-m-d H:i:s");