View Full Version : gmdate (PHP-releated)
SnakeBite
September 5th, 2002, 16:48
Hi. I've got some problems with some PHP code.
My computer is set to GMT+1, but PHP tells me I'm using GMT+2.
Why is this?
This is some of the code I'm using:
$date = gmdate("d.m.Y (F jS (l), Y)",mktime(date("H")+1,date("i"),date("s"),date("m"),date("d"),date("Y")));
This should return GMT+1 (GMT hour + 1)
Can anyone help me with this? :confused:
Nezzar
September 6th, 2002, 08:39
I'd suggest this:
$ts = time() - 3600;//get a simple timestamp (3600 is to fix this gmt +2 issue)
$date = gmdate("d.m.Y (F jS (l), Y)",$ts);
This is the only workaround I can think of ATM. And this is not a good one. This will work on your machine but if you upload it to your production it might return wrong values.
I'd suggest looking at the notes at php.net/gmdate or php.net/date
ammoQ
September 6th, 2002, 08:42
The reason is probably that your hardware clock is set to local time (GMT+1), while PHP thinks it's GMT, so PHP adds 1 to get GMT+1, thus resulting in GMT+2.
SnakeBite
September 17th, 2002, 17:55
Well, after some research I found this to work:
if(date("I") == "0") // Daylight Saving Time (DST)
$hour = date("H")+1;
else
$hour = date("H")+2;
$date = gmdate("d.m.Y H:i (h:i A)",mktime($hour,date("i"),date("s"),date("m"),date("d"),date("Y")));
Well, it returns the right time, so I will continue to use this and see if it still works when the time changes before I upload it. (I've used damn much time on these PHP probs.) Anyway, thanks for the help. ;)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.