I need to input a date in format, 26/12/1993 where 12 is month (december), I need to know a way to find the previous date (25/12/1993) and the next date (27/12/1993) using PHP.
Asked
Active
Viewed 153 times
0
-
1See http://stackoverflow.com/questions/3727615/adding-days-to-date-in-php – kuldeep.kamboj May 29 '13 at 08:53
2 Answers
1
Please check the below example:
<a href="home.php?date=<?= date('Y-m-d', strtotime(' -1 day')) ?>" class="prev_day" title="Previous Day" ></a>
<a href="home.php?date=<?= date('Y-m-d', strtotime(' +1 day')) ?>" class="next_day" title="Next Day" ></a>
It might help you.
take a look at get next and previous day with php
Community
- 1
- 1
Shreyos Adikari
- 12,089
- 19
- 71
- 81
0
Try using the PHP DateTime object
$date = new DateTime('26/12/1993');
$previous_day = $date->modify('-1 day');
$next_day = $date->modify('+1 day');
print $previous_day->date_format('m/d/Y');
print $next_day->date_format('m/d/Y');
RMcLeod
- 2,531
- 1
- 25
- 38