array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'datetime.settimestamp.php', 1 => 'DateTime::setTimestamp', ), 'up' => array ( 0 => 'class.datetime.php', 1 => 'DateTime', ), 'prev' => array ( 0 => 'datetime.settime.php', 1 => 'DateTime::setTime', ), 'next' => array ( 0 => 'datetime.settimezone.php', 1 => 'DateTime::setTimezone', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/datetime/datetime/settimestamp.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::setTimestamp -- date_timestamp_set — 以 Unix 时间戳的方式设置日期和时间
面向对象风格
过程化风格
以 Unix 时间戳的方式设置日期和时间。
跟 DateTimeImmutable::setTimestamp() 一样,但适用于 DateTime。
过程化版本将 DateTime 对象作为第一个参数。
object
仅过程化风格:由 date_create() 返回的 DateTime 类型的对象。此函数会修改这个对象。
timestamp
代表日期的 Unix 时间戳。DateTimeImmutable::modify()
使用 @
格式可以设置范围超过 int 的时间戳。
返回方法链修改后的 DateTime 对象。