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 DateTime object.
  • Create a DateInterval object with the number of days to add.
  • Call date_add() date/time function, and pass the DateTime and DateInterval objects as arguments.
  • date_add() returns a DateTime object on success, or False on failure.



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

$date1 = date_create( "2022-01-15" );
$dateInterval = DateInterval::createFromDateString( "8 days" );
$outputDate = date_add( $date1, $dateInterval );
echo $outputDate -> format( 'Y-m-d' );



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