note 93819 deleted from datetime.gettimestamp by aharvey
| From: | aharvey@php.net | Date: | Fri, 30 Oct 2009 05:06:26 +0000 |
| Subject: | note 93819 deleted from datetime.gettimestamp by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162275@lists.php.net to get a copy of this message | ||
Note Submitter: edwin dot h at clear dot net dot nz
Reason: 2
----
If you are using PHP < 5.3.0 you can use this function instead:
<?php
function DateTime_getTimestamp(&$dt) {
$dtz_original = $dt -> getTimezone();
$dtz_utc = new DateTimeZone("UTC");
$dt -> setTimezone($dtz_utc);
$year = intval($dt -> format("Y"));
$month = intval($dt -> format("n"));
$day = intval($dt -> format("j"));
$hour = intval($dt -> format("G"));
$minute = intval($dt -> format("i"));
$second = intval($dt -> format("s"));
$dt -> setTimezone($dtz_original);
return gmmktime($hour,$minute,$second,$month,$day,$year);
}
?>