Forum Moderators: coopster
my php (4.3.4) is giving confusing results for times, switching (apparently at random) between daylight savings time and normal time. The following code gives a summertime result for a couple of days (e.g. "Mon, 4 Jun 2007 23:01:25 +0100"), then normal time (e.g. ".... 22:01:25 +0000"), and so on:
$timenow = time();
echo date("r",$timenow);
It happens regardless of browsers and machines.
My hosting provider has no idea how this is happening, nor do I. The timestamp would be the same in both formats (right?), so I'm guessing it must be something in the php setup that determines whether it displays as summertime or not, and this is somehow getting messed up. But I know nothing about the server side of things.
Is there anything I can point the server people to that might solve this?
Thanks in advance!
It sounds like a very strange problem that you have described.
First off, time() is assumed in the date() function if no timestamp is provided, so using
date("r")
would produce the same result as your code (in theory).
Secondly, I would try the following code:
date("e");
This should display the actual "Timezone Identifier" that the server returns - that would be the first step in locating where the problem is. If the above code returns two different timezones, the problem most likely resides in the server itself, and most likely in the adjkerntz function (if using FreeBSD). Have your web host check /etc/localtime to make sure that it is correct.
Hope this helps,
SK
date("e") was added in php5, but I'm on 4.3.4. Instead I'm using date("I") as a workaround - adjusting the time depending on whether php thinks DST is set or not (and as I know that it is). It's far from ideal.
I'll mention your ideas to the host guys and see if it gives them any leads.
Much appreciated!