Menu Close

Get previous and next day with PHP

codeamend

Use the following code for current date with different format

Input

<?php
echo "Today is " . date("Y/m/d") . "<br>";
 
echo "Today is " . date("Y.m.d") . "<br>";
echo "Today is " . date("Y-m-d") . "<br>";
echo "Today is " . date("l");
?> 

Output

Today is 2020/09/15
Today is 2020.09.15
Today is 2020-09-15
Today is Tuesday

Use the following for previous date Tomorrow

Input

<?php
echo "Yesterday Date: " . date('Y-m-d', strtotime(' -1 day'));
?> 

Output

Tomorrow Date: 2020-09-14

Use the following for next date

Input

<?php
echo "Tomorrow Date: " . date('Y-m-d', strtotime(' +1 day'));
?> 

Output

Tomorrow Date: 2020-09-16

Share

Posted in PHP

You can also read...

Leave a Reply

Your email address will not be published.