If you are using PHP < 5.3.0 you can use this function instead:
<?php
function DateTime_setTimestamp(&$dt,$timestamp) {
$dtz_original = $dt -> getTimezone();
$dtz_utc = new DateTimeZone("UTC");
$dt -> setTimezone($dtz_utc);
$year = gmdate("Y",$timestamp);
$month = gmdate("n",$timestamp);
$day = gmdate("j",$timestamp);
$hour = gmdate("G",$timestamp);
$minute = gmdate("i",$timestamp);
$second = gmdate("s",$timestamp);
$dt -> setDate($year,$month,$day);
$dt -> setTime($hour,$minute,$second);
$dt -> setTimezone($dtz_original);
}
?>
DateTime::setTimestamp
(PHP 5 >= 5.3.0)
DateTime::setTimestamp — Sets the date and time based on an Unix timestamp
Descrierea
Sets the date and time based on an Unix timestamp.
Parametri
- unixtimestamp
-
Unix timestamp representing the date.
Valorile întroarse
Returns the modified DateTime.
DateTime::setTimestamp
edwin dot h at clear dot net dot nz
01-Oct-2009 08:55
01-Oct-2009 08:55
