note 29363 added to function.gmmktime

From: Date: Tue, 11 Feb 2003 11:25:40 +0000
Subject: note 29363 added to function.gmmktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-43778@lists.php.net to get a copy of this message
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... -- http://www.php.net/manual/en/function.gmmktime.php http://master.php.net/manage/user-notes.php?action=edit+29363 http://master.php.net/manage/user-notes.php?action=delete+29363 http://master.php.net/manage/user-notes.php?action=reject+29363

« previous php.notes (#43778) next »