DateTime
PHP Manual

DateTime::modify

(PHP 5 >= 5.2.0)

DateTime::modifyAlters the timestamp

Description

public DateTime DateTime::modify ( string $modify )
DateTime date_modify ( DateTime $object , string $modify )

Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime().

Parameters

object

Procedural style only: A DateTime object returned by date_create()

modify

String in a relative format accepted by strtotime().

Return Values

Returns the modified DateTime.

Changelog

Version Description
5.3.0Changed the return value from NULL to DateTime.

Examples

Example #1 A date_modify() example

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

The above example will output:

2006-12-13

See Also


DateTime
PHP Manual