DateTime::setTimestamp
date_timestamp_set
(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 对象。
参见
- DateTimeImmutable::setTimestamp() - Sets the date and time based on a Unix timestamp
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。
备份地址:http://www.lvesu.com/blog/php/datetime.settimestamp.php