Set the date and time based on a Unix timestamp:
<?php
$date=date_create();
date_timestamp_set($date,1371803321);
echo date_format($date,"U = Y-m-d H:i:s");
?>
Try it Yourself »
The date_timestamp_set() function sets the date and time based on a Unix timestamp.
date_timestamp_set(
object, unixtimestamp)
Parameter | Description |
---|---|
object | Required. Specifies a DateTime object returned by date_create(). This function modifies this object |
unixtimestamp | Required. Specifies a Unix timestamp representing the date |
Return Value: | Returns the DateTime object for method chaining. FALSE on failure |
---|---|
PHP Version: | 5.3+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!