0

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.

Jonas
  • 121,568
  • 97
  • 310
  • 388
r_a_k
  • 111
  • 2
  • 8

2 Answers2

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,348
  • 19
  • 73
  • 82
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,561
  • 1
  • 22
  • 38