php8.5
Home/ Manual/ datetime / datetime/ DateTime::setTimestamp

DateTime::setTimestamp

PHP function Edit on GitHub ✎

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

Sets the date and time based on an Unix timestamp

Description

Oop

DateTime::setTimestamp(int $timestamp): DateTime

Procedural

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.

Parameters

timestamp

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

Return Values

Modifiedobject

See Also

Source: reference/datetime/datetime/settimestamp.xml · from the official PHP manual (php/doc-en)