Thursday, September 4, 2025
HomeLanguagesHow to Get Next, Previous Day, Month, Year From Date In PHP

How to Get Next, Previous Day, Month, Year From Date In PHP

How to get next and previous day, month and year from given date in PHP. In this tutorial, you will learn you how to get next and previous day, month and year from given date in php.

This tutorial will guide you with examples of how to get next and previous day, month and year from given date in php.

How to Get Next, Previous Day, Month And Year From Date In PHP

Use following examples for get next, previous day, month, year from given data in php; is as follows:

  • How to Get Previous Day From Date In Php?
  • How to Get Next Day From Date In Php?
  • How to Get Previous Month From Date In Php?
  • How to Get Next Month From Date In Php?
  • How to Get Previous Year From Date In Php?
  • How to Get Next Year From Date In Php?

How to Get Previous Day From Date In Php?

You can see the following example of how to get previous day from date in php:

<?php
    $date = "2021-01-11";
    $newdate = date("Y-m-d",strtotime ( '-1 day' , strtotime ( $date ) )) ;
    echo $newdate;
?>

Output:

2021-01-10

How to Get Next Day From Date In Php?

You can see the following example of how to get next day from date in php:

<?php
    $date = "2021-01-11";
    $newdate = date("Y-m-d",strtotime ( '+1 day' , strtotime ( $date ) )) ;
    echo $newdate;
?>

output:

2021-01-12

How to Get Previous Month From Date In Php?

This example of how to get previous month from date in php:

<?php
    $date = "2021-01-11";
    $newdate = date("Y-m-d", strtotime ( '-1 month' , strtotime ( $date ) )) ;
    echo $newdate;
?>

Output:

2020-12-11

How to Get Next Month From Date In Php?

You can see the following example of how to get next month from date in php:

<?php
    $date = "2021-01-11";
    $newdate = date("Y-m-d", strtotime ( '+1 month' , strtotime ( $date ) )) ;
    echo $newdate;
?>

Output:

2021-02-11

How to Get Previous Year From Date In Php?

For find previous year from date in PHP, So, You can see the following example:

<?php
    $date = "2021-01-11";
    $newdate = date("Y-m-d",strtotime ( '-1 year' , strtotime ( $date ) )) ;
    echo $newdate;
?>

Output:

2020-01-11

How to Get Next Year From Date In Php?

For find next year from date in PHP, So, You can see the following example:

<?php
    $date = "2021-01-11";
    $newdate = date("Y-m-d",strtotime ( '+1 year' , strtotime ( $date ) )) ;
    echo $newdate;
?>

Output:

2022-01-11

Recommended PHP Tutorials

RELATED ARTICLES

Most Popular

Dominic
32261 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS