ID:               33871
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jeremy at techtrav dot com
 Status:           Feedback
 Bug Type:         Date/time related
 Operating System: Windows XP Apache 2
 PHP Version:      5.1.0b3
 Assigned To:      derick
 New Comment:

A better program would be:

#include <time.h>
#include <stdio.h>

main () {
  time_t t;
  struct tm *tstruct;

  tstruct = localtime ((time(&t), &t));
  printf("TZ=%s TZDST=%s is_dst:%d\n", _tzname[0], _tzname[1],
tstruct->tm_isdst);

}

is_dst is 0 if DST isn't in effect, or positive otherwise.
Although you cannot get the precise tz info, you can get the timezone
offset with ease.
there is a nice example here:
http://msdn.microsoft.com/library/en-us/vclib/html/_crt_time.asp but I
can't test it, because cygwin's win32 api doesn't export some required
structures (and I didn't installed MSVC yet).


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

[2005-08-05 13:36:05] [EMAIL PROTECTED]

to derick:
actually its not that difficult to guess the timezone on windows (with
the comming winfx api will be even easier).

After some research on the web and some testing:

#include <time.h>
main () {
  time_t t;
  localtime ((time(&t), &t)); // fill the _tzname var
  printf("TZ=%s TZDST=%s\n", _tzname[0], _tzname[1]);
}

with GMT outputs:
TZ=GMTST TZDST=GMTDT

_tzname[0] is the timezone abbr name. _tzname[1] is filled if the
current timezone has DST changes.

more testing:
Pacific time:
TZ=PST TZDST=PDT

Central time:
TZ=CST TZDST=CDT

Brasilia:
TZ=ESAST TZDST=ESADT

Brisbane:
TZ=EAST TZDST=

The problem here is that our DB doesn't have these abbreviations. But
with some trialing we could all tz settings that windows uses and link
them to the main db.

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

[2005-08-05 13:30:11] joerg dot klein at ifsam dot lu

hi
it seems that I have a related problem:

I am on GMT+1
for the following example the system time is 11:00
date("H:i");
=> 09:00

set system time-zone to GMT(+0)
date("H:i");
=> 09:00

set system time to 10:00
date("H:i");
=> 08:00

It seems that php don't have the correct timezone. This error occurs
since 5.1.0b3.

My box runs on win2000SP4 with the latest snapshot.

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

[2005-08-05 12:53:27] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

Sorry, but I've tested on windows and it works perfectly. Are you sure
you are using an up-to-date snapshot? And that means PHP 5.1.0 beta 3
is old...

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

[2005-08-04 17:01:09] jeremy at techtrav dot com

By the way I do have E_ALL turned on, on my machine.  After all I don't
run my windows box with PHP in production.  I use my windows box for
development. Our PHP production runs on OpenBSD servers.

I don't quite understand this comment of yours:

"Now, if we can find a way how PHP can guess the correct timezone from
your windows box "

PHP 5.0.4 reads my TZ perfectly and gives you the expected result.  Why
would PHP 5.1.X not be able to?

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

[2005-08-04 16:55:55] jeremy at techtrav dot com

okay I figured out how to set my time zone.
I ran the following code in PHP 5.0.4 and PHP 5.1.X and recieved the
same result

putenv("TZ=US/Central");
echo date('r', (strtotime('oct 25')+(86400*6)));

This would mean the bug is simply that PHP5.1.X is not looking at the
time zone on the local machine.

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

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/33871

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

Reply via email to