Set the date and time based on a Unix timestamp in PHP

Description

The following code shows how to set the date and time based on a Unix timestamp.

Example


/*from w ww  . j a va  2s .  c  o  m*/
<?php
    $date=date_create();
    date_timestamp_set($date,1371806321);
    echo date_format($date,"U = Y-m-d H:i:s");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone