PHP date_timestamp_set() Function

Example

Set the date and time based on Unix timestamp:

<?php
$date=date_create();
date_timestamp_set($date,1472988263);
echo date_format($date,"U = Y-m-d H:i:s");
?>

Running Instance

Definition and Usage

The date_timestamp_set() function sets the date and time based on Unix timestamp.

Syntax

date_timestamp_set(object,unixtimestamp);
Parameter Description
object Required. Specifies by date_create() The DateTime object returned. This function modifies this object.
unixtimestamp Required. Specifies the Unix timestamp representing the date.

Technical Details

Return Value: Returns the modified DateTime object. Returns FALSE if it fails.
PHP Version: 5.3+