This article demonstrates how to add one day to a date in PHP.

1. Using DateTime::modify() function

The DateTime::modify() function alters the timestamp of a DateTime object by adding or subtracting according to the specified date/time format. To advance a date to the next day, you can use the relative date format "+1 day".

Download  Run Code

 
If you prefer the procedural style functions, you can use the date_modify() function, which is an alias of DateTime::modify().

Download  Run Code

 
You can easily extend the solution to add any given number of days to a date. Consider the following example, which creates an extension method for this simple task:

Download  Run Code

2. Using DateTime::add() function

You can also modify a DateTime object with the DateTime::add() function, which adds the amount of days, months, years, hours, minutes, and seconds according to the specified DateInterval object. The DateInterval constructor expects a duration parameter for the interval specification. This format starts with P, which stands for period, and is followed by a duration period and a period designator. You can use the period designator D for adding or removing days, as specified by the duration period. Therefore, one day is P1D.

Download  Run Code

 
You may also use the procedural-style function date_add(), which is an alias of the object-oriented style function DateTime::add().

Download  Run Code

 
You can even write your own utility method for adding any number of days to the given date.

Download  Run Code

3. Using DateTime constructor

You can even use the DateTime constructor to add one day to a given date. The DateTime constructor returns a new DateTime object initialized from the specified date/time string. The idea is to use the English textual datetime description of "+1 day" to advance the given date by one. It can be used as shown below:

Download  Run Code

 
Additionally, if you just need to add one day to the current date, you can directly pass the relative date format "+1 day" to DateTime constructor, as shown below:

Download  Run Code

4. Using strtotime() function

This can be easily done using the strtotime() function, which converts the given date string into a Unix timestamp. You can use the English textual datetime description of "+1 day" to advance the given date by one.

Download  Run Code

 
Here’s a generic version of the above code that creates a utility method to add any number of days to the given date.

Download  Run Code

 
Finally, if you just want to find tomorrow’s date, you can simply pass "+1 day" to the strtotime() function.

Download  Run Code

That’s all there is to adding one day to a date in PHP.