Hi everyone. I'm new to these forums, I hope that somebody can help me.
I am having a problem with dates that I have stored in a MySQL database. They are displaying differently now (when we don't have DST) than they were last week (when we had DST).
I'm trying to figure out whether my PHP code is displaying the correct information. The code is:
$datetime = mktime(10,0,0,9,1,2007,1);
$date = mktime(0,0,0,9,1,2007,1);
echo date("Y-m-d H:i:s e",$datetime);
echo "<br>";
echo date("Y-m-d",$date);
echo "<br>";
echo date("I",$date);
I realise that the IS_DST parameter for mktime has been depreciated, but I have only used it in this code to illustrate the problem. I am not actually using mktime in the real code, I am creating $datetime and $date from a MySQL database.
The output is:
2007-09-01 09:00:00 UTC
2007-08-31
0
Before the clocks went back, the output would have been:
2007-09-01 10:00:00 BST
2007-09-01
1
It seems that the date("I",$date) is deciding whether the date is in BST, or not, based on the current date, not the date in the script.
Basically, all the dates and times on my site are now displayed in GMT (i.e. without DST). This isn't a problem, but during the summer they will be displayed in BST (i.e. with DST), even those times that are for dates in GMT.
Am I missing something obvious here, or is this how PHP5 should operate?
As far as displaying 31st August, instead of 1st September is concerned, this is explained here:
http://bugs.php.net/bug.php?id=461
I'm sure that this must have been covered elsewhere on the web, but I've tried searching, and can't find anything.