Set date and time based on Unix timestamp:
<?php$date=date_create();date_timestamp_set($date,1371803321);echo date_format($date,"U = Ymd H:i:s");?>The date_timestamp_set() function sets the date and time based on a Unix timestamp.
date_timestamp_set( object,unixtimestamp);
parameter | describe |
---|---|
object | Required. Specifies a DateTime object returned by date_create(). This function modifies the object. |
unixtimestamp | Required. Specifies a Unix timestamp representing a date. |
Return value: | Returns a DateTime object in the specified format. Returns FALSE on failure. |
---|---|
PHP version: | 5.3+ |