Daylight Savings Time

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I've got a newb question about Daylight Savings Time (DST).  First of
all here is some server info:

Apache 1.3.28
PHP 4.3.6
MySQL 3.23.49
Time is set to GMT

My goal is to be able to accurately record website visits according to
my local time (U.S. Central) every day of the year, no matter if I am
in DST or not.  I need a full datetime set of information (hour, min,
second, etc).

I have devised this line of code...


....but it does not help me when DST changes for me, as GMT does not
observe DST.

Next I tried this:

echo("server time is: " . date("H:i:s") . "<br>\n");
echo("new server time is: " . date("H:i:s") . "<br>\n");

And got these results:

server time is: 17:46:44
new server time is: 17:46:44

Apparently, the server does not allow me to change my timezone to
Central time (because the resulting times are the same).   The
application I am developing relies heavily on *accurate* time
information.  Anyone have any ideas how I can get this DST issue
figured out?

Re: Daylight Savings Time

Quoted text here. Click to load it

Then you *ALSO* need to be able to record whether or not DST was in
effect at the time or not.  Otherwise, there will be two GMT timestamps
that translate to the SAME Central timestamp (one CST, one CDT, and
that's the only thing different about them).

Quoted text here. Click to load it

Have you tried it?  UNIX time stamps are stored in GMT.  The presentation
of the time information is handled when you convert it to printable form.

Quoted text here. Click to load it

I recommend that you also print the time zone in the above example.
I doubt it has changed.   I don't see any doc that says you can
change the output of date() by changing TZ with putenv(), and worse,
I don't see any doc that says that changing TZ with putenv() will
not affect threads other than yours (for example, the Apache server
logs) for longer than your script runs.

There is some evidence on the PHP site in the commented version of
the putenv function page that it does, on at least one implementation,
affect the Apache logs when you change TZ.  There is also a suggestion
that if you invoke mktime(0,0,0,1,1,1970) after doing a putenv()
on the TZ environment variable, the change will take for your
program.  I have not tested this.

In the C world, I think there are some implementations where once
you call localtime(), changing TZ further will not change the time
zone localtime() returns unless you call some other function not
available in PHP (tzset()).

Quoted text here. Click to load it

If you really want accurate time information, I suggest storing it
in GMT.

                        Gordon L. Burditt

Site Timeline