PHP | date_modify() Function Last Updated : 18 May, 2018 Comments Improve Suggest changes Like Article Like Report 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. Syntax: date_modify(DateTime $object, string $modify); Parameters: 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 : php <?php // PHP program to illustrate date_modify() // function // creating DateTime object $date=date_create("2018-04-08"); // calling of date modify function // with two required parameters date_modify($date, "+15 days"); // printing the modified date in "y-m-d" format echo date_format($date, "Y-m-d"); ?> Output: 2018-04-13 Program 2: This program will be increase months by one php <?php // PHP program to illustrate date_modify() // function // creating a DateTime object $date = date_create('2000-10-14'); // calling date_modify function with // two required parameters date_modify($date, '+1 month'); // printing the modified date echo date_format($date, 'Y-m-d'); ?> Output: 2000-11-14 Reference http://php.net/manual/en/datetime.modify.php Comment More infoAdvertise with us Next Article PHP | date_modify() Function P priya_1998 Follow Improve Article Tags : Web Technologies PHP PHP-date-time PHP-function Similar Reads PHP | DateTime modify() Function The DateTime::modify() function is an inbuilt function in PHP which is used to modify or can alter the timestamp of a DateTime object. Syntax: Object oriented style: DateTime DateTime::modify( string $modify ) Procedural style: DateTime date_modify( DateTime $object, string $modify ) Parameters: Thi 2 min read PHP | DateTimeImmutable modify() Function The DateTimeImmutable::modify() function is an inbuilt function in PHP which is used to modify or alter the timestamp of the created DateTimeImmutable object. Syntax: DateTimeImmutable DateTimeImmutable::modify( string $modify ) Parameters: This function uses two parameters as mentioned above and de 2 min read PHP | date_parse() Function The date_parse() is an inbuilt function in PHP which is used to find the detailed information about a specified date. This function returns an associative array of detailed information for a specified date on success and returns FALSE on failure Syntax: date_parse($date) Parameters Used: The date_pa 2 min read PHP | date_offset_get() Function The date_offset_get() function is an inbuilt function in PHP which is used to returns the timezone offset. This function returns the timezone offset in seconds from UTC (Universal Time Coordinated) on success or FALSE on failure. Syntax: Procedural Style: int date_offset_get( $object ) Object Orient 1 min read PHP date_sub() Function The date_sub() function is an inbuilt function in PHP that is used to subtract days, months, years, hours, minutes, and seconds from given date. This function returns a DateTime object on success and FALSE on failure. Syntax: date_sub($object, $interval)Parameters: The date_sub() function accepts tw 2 min read Like