note 29363 deleted from function.gmmktime by sniper
| From: | sniper@php.net | Date: | Tue, 04 Nov 2003 13:12:40 +0000 |
| Subject: | note 29363 deleted from function.gmmktime by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59886@lists.php.net to get a copy of this message | ||
Note Submitter: mark.page@transactgroup.net
----
This function returns unpredictable results on Solaris.
For those who get discrepancies but don't have access
to tinker with the PHP installation here is a hack
to get around it.
It relies on the fact that gmdate() is reliable (which it
seems to be) and makes the appropriate correction
to the timestamp.
function gmmktime_nobug($h,$i,$s,$m,$d,$y){
$o=gmmktime($h,$i,$s,$m,$d,$y);
$b=gmdate("Y m d H i s");
$b=explode(" ",$b);
$c["y"]=$b[0];
$c["m"]=$b[1];
$c["d"]=$b[2];
$c["h"]=$b[3];
$c["i"]=$b[4];
$c["s"]=$b[5];
while(list($k,$v)=each($c)){
if(${$k}!=$v){$f=1;break;}
}
if (!$f){return $o;}
$a=gmmktime(
$c["h"],$c["i"],$c["s"],$c["m"],$c["d"],$c["y"]
);
return 2*$o-$a;
}
Let's hope that gmmktime() improves in the next release...