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

ParameterIs RequiredDescription
objectRequired.DateTime object returned by date_create().
unixtimestampRequired.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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions