PHP date_timestamp_set() Function
Definition
The date_timestamp_set() function sets the date and time based on a Unix timestamp.
Syntax
PHP date_timestamp_set() Function has the following syntax.
date_timestamp_set(object,unixtimestamp);
Parameter
Parameter | Is Required | Description |
---|---|---|
object | Required. | DateTime object returned by date_create(). |
unixtimestamp | Required. | Unix timestamp representing the date |
Return
PHP date_timestamp_set() Function returns the DateTime object. FALSE on failure.
Example
Set the date and time based on a Unix timestamp:
<?php/* w ww .j av a2 s. c o m*/
$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.