The date_timestamp_set() function sets the date and time based on a Unix timestamp.
PHP date_timestamp_set() Function has the following syntax.
date_timestamp_set(object,unixtimestamp);
Parameter | Is Required | Description |
---|---|---|
object | Required. | DateTime object returned by date_create(). |
unixtimestamp | Required. | Unix timestamp representing the date |
PHP date_timestamp_set() Function returns the DateTime object. FALSE on failure.
Set the date and time based on a Unix timestamp:
<?php
$date=date_create();
date_timestamp_set($date,1234500000);
echo date_format($date,"U = Y-m-d H:i:s");
?>
The code above generates the following result.