PHP - Function date_modify()


Advertisements


Syntax

void date_modify ( DateTime $object, string $modify )

void DateTime::modify ( string $modify )

Definition and Usage

These functions alter the timestamp given in the passed object.

The above two functions are equivalent and any of the functions can be used as shown below in the example.

Parameters

Sr.No Parameter & Description
1

object(Required)

DateTime object

2

modify(Required)

String in a relative format

Return Value

It returns NULL on success or FALSE on failure.

Example

Following is the usage of this function −

<?php
   $date = new DateTime("1990-12-12");
   $date->modify("+1 day");
   
   echo $date->format("Y-m-d");
?> 

This will produce the following result −

1990-12-13

php_function_reference.htm

Advertisements