How to Add Days to Date in PHP

How to Add Days to Date in PHP

In this article, you will learn how to add days to date in PHP.


Let’s say you have a string variable named ‘a’ with the value of a date.


$a = date_create("03-03-2021");

Add Days to Date


In order to add days to date, you can use the date_create() method, date_add() method, date_interval_create_from_date_string() method and date_format() method.


$a = date_create("03-03-2021"); // Add 10 days to variable 'a'
date_add($a, date_interval_create_from_date_string("10 days")); echo date_format($a,"d-m-Y");
// 13-03-2021

Note: The date_create() method functions by creating a DateTime object from a supplied string. The date_add() method functions by adding days, months, years, hours, minutes or seconds to the first supplied argument. The date_interval_create_from_date_string() functions by creating a DateInterval from the supplied string. The date_format() method functions by returning a formatted date.