DateTime::setTimestamp

It sets the date and time based on an Unix timestamp .
Example

<?php
$date = new DateTime();
echo $date->format(‘U = Y-m-d H:i:s’) . “<br />”;

$date->setTimestamp(1181503727);
echo $date->format(‘U = Y-m-d H:i:s’) ;
?>

Output

1335329861 = 2012-04-25 10:27:41
1181503727 = 2007-06-11 00:58:47

Share