The date_modify() function is an inbuilt function in PHP. Through the help of this function, we can modify or can alter the timestamp of DateTime object. The DateTime object and string modify are parameters in the calling function.
date_modify(DateTime $object, string $modify);
The function accepts two parameters as described below:
- $object : This is a mandatory parameter. It specifies a DateTime object returned by date_create() .This object is modified by the above mentioned function.
- $modify : This is also a mandatory parameter. This specifies a date/time string. It is incremented or decremented to modify the DateTime object.
Return Values :
This function returns a DateTime object on success. And returns FALSE on failure.
Below programs illustrate the date_modify() function :
Program 1 :
Program 2: This program will be increase months by one
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.