DateTime
PHP 手册

DateTime::modify

(PHP 5 >= 5.3.0)

DateTime::modifyAlters the timestamp

说明

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().

参数

object

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

modify

String in a relative format accepted by strtotime().

返回值

Returns the modified DateTime.

范例

Example #1 A date_modify() example

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

上例将输出:

2006-12-13

参见


DateTime
PHP 手册