Friday, September 5, 2025
HomeLanguagesPHP Add Days, Month, Year to Date

PHP Add Days, Month, Year to Date

Add days, months, and years to date in PHP; Through this tutorial, we will learn how to add days, month and year to date in PHP.

How to Add Days, Month, Year to Date in PHP

Use the following example to add days, months, and year to date in PHP; as follows:

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

PHP Add Days to Date

Use the following PHP code to add days to date; as follows:

<?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

Use the following php code to add month to date; as follows:

<?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

Use the following php code to add year to date; as follows:

<?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

RELATED ARTICLES

Most Popular

Dominic
32265 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS