phpday 2027 - Call for Papers

DateTime::setTimestamp

date_timestamp_set

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

DateTime::setTimestamp -- date_timestamp_set — Sets the date and time based on an Unix timestamp

Опис

Об'єктно-орієнтований стиль

public function DateTime::setTimestamp(int $timestamp): DateTime

Процедурний стиль

function date_timestamp_set(DateTime $object, int $timestamp): DateTime

Sets the date and time based on an Unix timestamp.

Like DateTimeImmutable::setTimestamp() but works with DateTime.

The procedural version takes the DateTime object as its first argument.

Параметри

object

Тільки процедурний стиль: об'єкт DateTime повертається функцією date_create(). Вона змінює цей об'єкт.

timestamp

Unix timestamp representing the date. Setting timestamps outside the range of int is possible by using DateTimeImmutable::modify() with the @ format.

Значення, що повертаються

Повертає змінений об'єкт DateTime для ланцюжків методів.

Помилки/виключення

Throws a DateObjectError if the object has not been correctly initialized, for example when the constructor of a child class does not call the parent constructor.

Журнал змін

Версія Опис
8.3.0 A DateObjectError is now thrown if the object has not been correctly initialized; previously, an Error was thrown.

Прогляньте також

+add a note

User Contributed Notes

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