PHP Add Days, Month, Year From Date

PHP add days, months, and years from date; In this tutorial, i am going to show you how to add days, month and year to date in PHP.

PHP Add Days, Month, Year From Date

Follow the below given examples to add days, months, and year from date in PHP:

  • PHP Add Days to Date
  • PHP Add Months to Date
  • PHP Add Year to Date

PHP Add Days to Date

Let’s see the following example to add days from date in php:

<?php
  
    $date = "2022-01-01";
    $newDate = date('Y-m-d', strtotime($date. ' + 3 days'));
  
    echo $newDate;
  
?>

The output of the above code; as follows:

2022-01-04

PHP Add Months to Date

Let’s see the following example to add months from date in php:

<?php
  
    $date = "2022-01-01";
    $newDate = date('Y-m-d', strtotime($date. ' + 3 months'));
  
    echo $newDate;
  
?>

The output of the above code; as follows:

2022-04-01

PHP Add Year to Date

Let’s see the following example to add year from date in php:

<?php
  
    $date = "2022-02-01";
    $newDate = date('Y-m-d', strtotime($date. ' + 5 years'));
  
    echo $newDate;
  
?>

The output of the above code; as follows:

2027-02-01

Recommended PHP Tutorials

Be First to Comment

Leave a Reply

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