PHP date_timestamp_set()Functions

PHP Date/TimePHP Date/Time Reference Manual

Examples

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");
?>

Run example »

Definition and Usage

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

Syntax

date_timestamp_set(object,unixtimestamp);

Parameters Description
object Required. Specifies a DateTime object returned bydate_create()the returned DateTime object. This function modifies the object.
unixtimestamp Required. Specifies the Unix timestamp representing the date.

Technical Details

Return value: Returns a DateTime object in the specified format. Returns FALSE on failure.
PHP version: 5.3+


PHP Date/TimePHP Date/Time Reference Manual Other Extensions