ID:               14391
 Comment by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           No Feedback
 Bug Type:         Date/time related
 Operating System: Windows 2000 Server
 PHP Version:      4.0.6
 New Comment:

I use Win2K.I got this problem too. But after I updated to php 4.2.1
version, they are gone. It works well on php 4.2.1 (or higher version,
I guess).

Kae


Previous Comments:
------------------------------------------------------------------------

[2002-12-12 09:03:48] [EMAIL PROTECTED]

Same problem - runing at the same time 2 systems:

On Windows NT 5.0 build 2195 PHP 4.1.1 on GMT zone:

echo  (gmdate("U") . "<br>");  //1039704601
echo  (date ("U") . "<br>");   //1039704601
echo  (mktime() . "<br>");     //1039704601
echo  (gmmktime() . "<br>");   //1039701001
echo  (time() . "<br>");       //1039704601

On Linux webdev 2.4.19 #1  PHP 4.2.2 on EDT zone:

echo  (gmdate("U") . "<br>");  //1039704601
echo  (date ("U") . "<br>");   //1039704601
echo  (mktime() . "<br>");     //1039704601
echo  (gmmktime() . "<br>");   //1039686601
echo  (time() . "<br>");       //1039704601

Peter

------------------------------------------------------------------------

[2002-08-04 01:00:10] [EMAIL PROTECTED]

No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2002-07-03 19:54:16] [EMAIL PROTECTED]

Could you please retry with a current snapshot or CVS-checkout? There
have been changes to mktime, so this problem might be already fixed in
CVS.

Please reopen the case if the problem persists.

Thanks for helping!


------------------------------------------------------------------------

[2002-07-03 15:21:20] [EMAIL PROTECTED]

Here's a different perspective:  I've been duplicating examples in
Python, Perl, Tcl, and PHP, thinking my next book may be full of such. 
One of my examples converts between an ASCII GMT representation and the
local machine's seconds since the epoch.  I did the example in the
other languages before trying PHP.  Tcl works "out of the box".  In
Python and Perl, I found ways of getting the gmt-to-local time
differential and used that differential to adjust the result produced
by mktime to create something similar to PHP's mktime.  (It's not well
tested but doesn't have the bug PHP's mktime has.  I get correct
results for daylight and nondaylight local times.)  In PHP, I can't
find tools sufficient to calculate that time differential.  HERE's THE
POINT:  All these languages seem to rely on the same basic C library. 
If it can be done using those C library tools (however indirectly) in
some of them it ought to be possible in all.

J Adrian Zimmer

------------------------------------------------------------------------

[2002-04-17 21:03:39] [EMAIL PROTECTED]

Hi,

This is my first post to PHP-DEV.

I was stuck too when I tried to get timezone by subtracting
the return value of mktime() from that of gmmktime().

I've inspected the codes, and I guess this may be a complicated
and weird bug produced by glibc, MS CRT library,
ext/standard/datetime.c.

/* ------------------------------------------------------ */
#include <stdio.h>
#include <time.h>

int main( int argc, char **argv )
{
        struct tm tm_d = { 0, 0, 0, 1, 0, 70, 0, 0, -1 };

        int seconds;
        int     gmadjust;
        int     is_dst;

        is_dst = tm_d.tm_isdst;
        seconds = mktime( &tm_d );

        gmadjust = -(is_dst ? timezone - 3600: timezone );
        printf( "%d\n", seconds );
        seconds += gmadjust;
        printf( "%d %d\n", tm_d.tm_isdst, seconds );
}
/* ------------------------------------------------------ */

I wrote this trivial program, and compiled and run
in two different ways.

[win32 - mingw(gcc 2.95.3) with msvcrt.dll under w2k]
c:\blah> gcc -o tztest.exe tztest.c
c:\blah> set TZ=JST-9:00
c:\blah> tztest.exe

-1
-1 35999

c:\blah> set TZ=PST+8:00
c:\blah> tztest.exe

28800
0 0

[linux - gcc 3.04 and glibc-2.2.4]

$ gcc -o tztest tztest.c
$ env TZ="JST -9:00" ./tzdiff

-32400
0 0

$ env TZ="PST +8:00" ./tzdiff

28800
0 0

[What those results mean]

(a) mktime() must return -1 if the specified broken-down time cannot
be
    represented as calendar time according to its spec.

(b) When the given timezone is more eastward than GMT,
    libc's mktime() should fail (and return -1)
    when tm.tm_hour < ( -timezone / 3600 ) because of (a)

(c) glibc doesn't seem to comform to (b).

(d) MS's libc(msvcrt) does (b).

(e) If mktime() is called with tm.tm_isdst set to less than zero,
    mktime() routine determines if DST is to be applied in the
specified
    timezone, and should set tm_isdst to 1 (applied) or 0 (not
applied).

(f) glibc does (e) well.

(g) MS's libc(msvcrt) doesn't do (e) in case of (a) and leaves
tm.tm_isdst be.

(h) php_mktime() in ext/standard/datetime.c doesn't care about case
(b).

-----------------------------------

Sorry if this is not the point.


Moriyoshi Koizumi

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/14391

-- 
Edit this bug report at http://bugs.php.net/?id=14391&edit=1

Reply via email to