CakeFest 2024: The Official CakePHP Conference

DateTime::setDate

date_date_set

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

DateTime::setDate -- date_date_set设置日期

说明

面向对象风格

public DateTime::setDate(int $year, int $month, int $day): DateTime

过程化风格

date_date_set(
    DateTime $object,
    int $year,
    int $month,
    int $day
): DateTime

将 DateTime 对象的当前日期重置为其它日期。

DateTimeImmutable::setDate() 一样,但适用于 DateTime,且更改现有对象。

过程化版本将 DateTime 对象作为第一个参数。

参数

object

仅过程化风格:由 date_create() 返回的 DateTime 类型的对象。此函数会修改这个对象。

year

年份。

month

月份。

day

日。

返回值

返回方法链修改后的 DateTime 对象。

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top