If anybody cares,

gmmktime returning completly bogus results. It can be easly checked out
by manually setting TZ shell variable.

Lets try it like this:

TZ=GMT+1 php -r "echo gmmktime();"

gives 1100292805

TZ=GMT+2 php -r "echo gmmktime();"

gives 1100289207

TZ=GMT+3 php -r "echo gmmktime();"

gives 1100285610

 But it should return always the same time (ok, few seconds here and
there, needed to type each command..) no matter which timezone is set.


Why ? Because 'tm_gmtoff' (and gmadjust manually calculated from
'timezone' and 'is_dst' in cases where tm_gmtoff is not available) shows
number of seconds EAST from GMT (man localtime is your friend here). So
to get GMT time from, we have to _substract_ this number from localtime,
and what is php currently doing, is adding it to localtime, which can't
be a good thing no matter how you look at it (-:


 So the fix is easy:

--- ext/standard/datetime.c.orig        Fri Nov 12 22:35:04 2004
+++ ext/standard/datetime.c     Fri Nov 12 22:35:33 2004
@@ -256,7 +256,7 @@
            gmadjust = -(is_dst ? timezone - 3600 : timezone);
 #endif
 #endif
-               seconds += gmadjust;
+               seconds -= gmadjust;
        }
  
        RETURN_LONG(seconds);

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to