note 93821 deleted from datetime.settimestamp by danielc
| From: | danielc@php.net | Date: | Sat, 24 Apr 2010 20:47:43 +0000 |
| Subject: | note 93821 deleted from datetime.settimestamp by danielc | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168600@lists.php.net to get a copy of this message | ||
Note Submitter: edwin dot h at clear dot net dot nz
----
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);
}
?>