array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'datetime.add.php', 1 => 'DateTime::add', ), 'up' => array ( 0 => 'class.datetime.php', 1 => 'DateTime', ), 'prev' => array ( 0 => 'class.datetime.php', 1 => 'DateTime', ), 'next' => array ( 0 => 'datetime.construct.php', 1 => 'DateTime::__construct', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/datetime/datetime/add.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
DateTime::add -- date_add — 修改 DateTime 对象,增加天、月、年、小时、分钟以及秒的数量。
面向对象风格
过程化风格
将指定的 DateInterval 对象到 DateTime 对象。
跟 DateTimeImmutable::add()一样,但适用于 DateTime。
过程化版本将 DateTime 对象作为它的第一个参数。
object
仅过程化风格:由 date_create() 返回的 DateTime 类型的对象。此函数会修改这个对象。
interval
DateInterval 对象。
返回方法链修改后的 DateTime 对象。