ID: 33545 User updated by: xuefer at 21cn dot com Reported By: xuefer at 21cn dot com -Status: Feedback +Status: Open Bug Type: Date/time related -Operating System: cygwin +Operating System: cygwin fastcgi PHP Version: 5CVS-2005-07-02 (dev) Assigned To: derick New Comment:
$ export TZ=GMT $ echo $TZ GMT $ gdb --args ./sapi/cgi/php.exe -b 1026 (gdb) br main Breakpoint 1 at 0x71a0ab: file /home/Xuefer/src/php5/sapi/cgi/cgi_main.c, line 946. (gdb) r Starting program: /usr/src/php5-debug/sapi/cgi/php.exe -b 1026 Breakpoint 1, main (argc=3, argv=0x10031e60) at /home/Xuefer/src/php5/sapi/cgi/cgi_main.c:946 946 { (gdb) p getenv("PATH") $3 = 268634357 (gdb) p getenv("_") $4 = 268637882 (gdb) p getenv("WINDIR") $5 = 268632983 (gdb) p getenv("OS") $6 = 268633155 no problem with other env, except TZ (gdb) p getenv("TZ") $1 = 0 (gdb) l php_module_startup (gdb) br 1401 Breakpoint 2 at 0x653624: file /home/Xuefer/src/php5/main/main.c, line 1401. (gdb) c Continuing. Breakpoint 2, php_module_startup (sf=0x7a81e0, additional_modules=0x0, num_additional_modules=0) at /home/Xuefer/src/php5/main/main.c:1401 1401 tzset(); (gdb) p getenv("TZ") $3 = 0 (gdb) n 1412 le_index_ptr = zend_register_list_destructors_ex(NULL, NULL, "index pointer", 0); (gdb) p (char*)getenv("TZ") $5 = 0x100301a3 " -8" (gdb) i'm not sure it's problem of cygwin or php of corse, as cygwin is not supported by php. same problem in php4, but there's no warning with date() strtodate(). putenv("TZ=GMT"); helps, but not putenv("TZ"); in php script before date() <?php echo "<pre>"; echo "\nwith putenv TZ:"; putenv("TZ"); echo date("H"); echo "\nwith putenv TZ=GMT:"; putenv("TZ=GMT"); echo date("H"); echo "\nwith putenv TZ=GMT-8:"; putenv("TZ=GMT-8"); echo date("H"); echo "\nwith putenv TZ= -8:"; // 3 spaces before + putenv("TZ= -8"); echo date("H"); ?> ==================== with putenv TZ: Warning: date(): Cannot find any timezone setting in /cygdrive/d/www/test/test.php on line 5 with putenv TZ=GMT:10 with putenv TZ=GMT-8: Warning: date(): Cannot find any timezone setting in /cygdrive/d/www/test/test.php on line 11 with putenv TZ= -8: Warning: date(): Cannot find any timezone setting in /cygdrive/d/www/test/test.php on line 14 ==================== i have no problem with simple test program but no idea on how to go on to trace php int main() {} $ gdb ./a.exe (gdb) br main Breakpoint 1 at 0x401056 (gdb) r Starting program: /home/Xuefer/a.exe Breakpoint 1, 0x00401056 in main () (gdb) p (char*)getenv("TZ") $2 = 0x4b08cb "GMT" ---------------- gcc -v gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) bash --version GNU bash, version 2.05b.0(1)-release (i686-pc-cygwin) autoconf --version autoconf (GNU Autoconf) 2.59 http://sourceforge.net/tracker/?func=detail&atid=305470&aid=459385&group_id=5470 Previous Comments: ------------------------------------------------------------------------ [2005-07-02 12:21:00] [EMAIL PROTECTED] Apparently the TV environment variable *is* set... you need to try to figure out where this happens. If it's not set by yourself, you should try to figure out why cygwin does this - that's obviously not PHP's problem. ------------------------------------------------------------------------ [2005-07-02 06:45:15] xuefer at 21cn dot com Description: ------------ PHP 5.1.0-dev (cgi-fcgi) (built: Jun 28 2005 11:49:30) (DEBUG) unset TZ && php.exe a.php Content-type: text/html Warning: date(): Cannot find any timezone setting in /usr/src/php5-debug/a.php on line 2 /usr/src/php5-debug/a.php(2) : Warning - date(): Cannot find any timezone setting putenv("TZ"); before date() is ok however. ------ 96 env = getenv("TZ"); 97 if (env) { 98 return env; 99 } (gdb) br 98 Breakpoint 1 at 0x42453b: file /usr/src/php5-src/ext/date/php_date.c, line 98. (gdb) r Breakpoint 1, guess_timezone () 98 return env; (gdb) p env $1 = 0x100301a3 " -8" but i can't figure where env TZ is set, not my shell nor my script Reproduce code: --------------- <?php echo date("Y:m:d"); ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33545&edit=1