Menu Close

Get previous and next day with PHP

0
(0)

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

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Share

Posted in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

You can also read...