php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27175 forget to call tzset(3) when php starts
Submitted: 2004-02-07 06:20 UTC Modified: 2004-02-08 22:59 UTC
From: sagawa at sohgoh dot net Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.3.5RC2 OS: CYGWIN_NT-5.1 1.5.7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sagawa at sohgoh dot net
New email:
PHP Version: OS:

 

 [2004-02-07 06:20 UTC] 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)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-07 22:51 UTC] 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-08 22:59 UTC] iliaa@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 06:01:32 2024 UTC