ID: 27175 Updated by: [EMAIL PROTECTED] Reported By: sagawa at sohgoh dot net -Status: Open +Status: Closed Bug Type: Date/time related Operating System: CYGWIN_NT-5.1 1.5.7 PHP Version: 4.3.5RC2 New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2004-02-07 22:51:44] sagawa at sohgoh dot net I made a patch for this problem. --- php-4.3.5RC2/main/main.c.orig 2004-01-29 09:09:26.000000000 +0900 +++ php-4.3.5RC2/main/main.c 2004-02-08 12:52:59.494820800 +0900 @@ -1137,6 +1137,9 @@ int php_module_startup(sapi_module_struc #if HAVE_SETLOCALE setlocale(LC_CTYPE, ""); #endif +#if HAVE_TZSET + tzset(); +#endif #if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK)) /* start up winsock services */ ------------------------------------------------------------------------ [2004-02-07 06:20:15] sagawa at sohgoh dot net Description: ------------ php_localtime_r(almost localtime_r(3)) does not call tzset(3) in some libc (eg. Cygwin, NetBSD). Thus we need call tzset(3) before calling php_localtime_r. http://bugs.php.net/bug.php?id=4732 If we set TZ env. via putenv PHP function, tzset(3) is called internally. But lack of calling tzset(3) before PHP script execution, and some functions. Therefore I get incorect result from php_localtime_r. php_localtime_r is used in these files. ext/calendar/cal_unix.c ext/calendar/easter.c ext/dbase/dbf_misc.c ext/standard/datetime.c ext/standard/info.c main/main.c Reproduce code: --------------- % cat tztest.php <?php /* date() is just example, shows incorrectly */ echo date("r (T)"),"\n"; /* works fine.. because putenv("TZ=JST-9") calls tzset */ putenv("TZ=JST-9"); echo date("r (T)"),"\n"; ?> % TZ="JST-9" php -q tztest.php Expected result: ---------------- Sat, 7 Feb 2004 20:18:15 +0900 (JST) Sat, 7 Feb 2004 20:18:15 +0900 (JST) Actual result: -------------- Sat, 7 Feb 2004 11:18:15 +0000 () Sat, 7 Feb 2004 20:18:15 +0900 (JST) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27175&edit=1