PHP Tutorial - PHP date_modify() Function






Definition

The date_modify() function modifies the timestamp.

Syntax

PHP date_modify() Function has the following syntax.

date_modify(object,modify);

Parameter

ParameterIs RequiredDescription
objectRequired.DateTime object returned by date_create()
modifyRequired.Date/time string

Return

PHP date_modify() Function returns a DateTime object on success. FALSE on failure.

Example

Add 15 days to the timestamp


<?php
$date=date_create("2013-05-01");
date_modify($date,"+15 days");
echo date_format($date,"Y-m-d");
?>

The code above generates the following result.