In this tutorial, you shall learn how to add specific number of days to a given date in PHP using date_add() function, with example programs.
PHP – Add Specific Number of Days to a Date
To add specific number of days to a Date in PHP
- Create
DateTimeobject. - Create a
DateIntervalobject with the number of days to add. - Call
date_add()date/time function, and pass theDateTimeandDateIntervalobjects as arguments. date_add()returns aDateTimeobject on success, orFalseon failure.
Examples
1. Add 8 days to given date
In the following program, we shall take two a date in $date1 and add 8 days to this date using date_add() function.
PHP Program
</>
Copy
<?php
$date1 = date_create( "2022-01-15" );
$dateInterval = DateInterval::createFromDateString( "8 days" );
$outputDate = date_add( $date1, $dateInterval );
echo $outputDate -> format( 'Y-m-d' );
?>
Output

Conclusion
In this PHP Tutorial, we learned how to add specific number of days to given date in PHP, using date_add() function.
