Sets the date and time based on an Unix timestamp
Syntax
date_timestamp_set ( DateTime $object , int $timestamp ) : DateTime
Parameters
object
A DateTime object returned by date_create(). The function modifies this object.
timestamp
Unix timestamp representing the date.
Return
Returns the DateTime object for method chaining or FALSE on failure.
Examples
1 · object timestamp
<? $object = date_create(); $timestamp = date_timestamp_get($object); date_timestamp_set($object, $timestamp); echo date_format($object, "U = Y-m-d H:i:s"); ?>
1696118716 = 2023-10-01 00:05:16
2 · Return
<? $object = date_create(); $timestamp = date_timestamp_get($object); $return = date_timestamp_set($object, $timestamp); echo date_format($return, "U = Y-m-d H:i:s"); ?>
1696118716 = 2023-10-01 00:05:16