PHP 5 >= 5.3.0, PHP 7, PHP 8
DateTime::setTimestamp - Sets the date and time based on an Unix timestamp
Code Examples

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

Procedural style

DateTimedate_timestamp_set DateTimeobject inttimestamp



Procedural style only: A DateTime object returned by date_create. The function modifies this object.


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

Return Values

Returns the DateTime object for method chaining or false on failure.

Related Functions

Example of DateTime::setTimestamp

Show all examples for DateTime::setTimestamp

PHP Version:

Function DateTime::setTimestamp:

Date and Time Functions

Most used PHP functions