note 94848 added to datetime.settimestamp
| From: | julien_muetton at carpe-hora dot com | Date: | Sat, 28 Nov 2009 12:48:46 +0000 |
| Subject: | note 94848 added to datetime.settimestamp | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163360@lists.php.net to get a copy of this message | ||
Hi there,
if you use previous code on x64 architecture and got a php version prior to 5.2.7 (debian lenny for
instance), beware of bug #45038 (http://bugs.php.net/bug.php?id=45038)
a solution can be to use following code:
<?php
function setTimestamp($timestamp) {
$thisz_original = $this -> getTimezone()->getName();
$thisz_utc = new DateTimeZone('UTC');
$this -> setTimezone($thisz_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);
$this -> setDate($year,$month,$day);
$this -> setTime($hour,$minute,$second);
$this -> setTimezone(new DateTimeZone($thisz_original));
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 77.198.88.239
----
Manual Page -- http://www.php.net/manual/en/datetime.settimestamp.php
Edit -- https://master.php.net/note/edit/94848
Del: integrated -- https://master.php.net/note/delete/94848/integrated
Del: useless -- https://master.php.net/note/delete/94848/useless
Del: bad code -- https://master.php.net/note/delete/94848/bad+code
Del: spam -- https://master.php.net/note/delete/94848/spam
Del: non-english -- https://master.php.net/note/delete/94848/non-english
Del: in docs -- https://master.php.net/note/delete/94848/in+docs
Del: other reasons-- https://master.php.net/note/delete/94848
Reject -- https://master.php.net/note/reject/94848
Search -- https://master.php.net/manage/user-notes.php