Hello Reader's if you have the current date and you want to get some past dates or future dates then here you can see it. PHP offers you to use inbuilt function strtotime.
Lets see how you can adjust the dates with this.
Here you will get the next date of current date
<?php
$stop_date = date('Y-m-d H:i:s', strtotime("2015-12-30 15:21:10"));
echo 'date before day adding: '.$stop_date;
$stop_date = date('Y-m-d H:i:s', strtotime('+1 day', $stop_date));
echo ' Incremented date: '.$stop_date;
?>
Output:-
2015-12-31 15:21:10
Now see if you want to get the past date
<?php
$stop_date = date('Y-m-d H:i:s', strtotime("2015-12-30 15:21:10"));
echo 'date before day adding: '.$stop_date;
$stop_date = date('Y-m-d H:i:s', strtotime('-1 day', $stop_date));
echo ' Incremented date: '.$stop_date;
?>
Output:-
2015-12-29 15:21:10
0 Comment(s)