Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MacDonaldsd

macrumors 65816
Original poster
Hi all,

Im manipulating dates in PHP and then saving them for latter use in the GMT format.

(I will be using it in RSS in the format Wed, 13 Feb 2008 17:22:00 GMT).

The problem is when you store a date you do not get the exact time in the summer as it is 1hour ahead so you have to put for example:

Sun, 1 Jun 2008 14:00:00 GMT -0100

Is there anyway of finding out using php whether daylight saving is in effect on the given date so the appropriate adjustment can be made ?
 
Thanks for that but I have a problem it always returns 0

First is of each date is done using date()
Seconds using gmdate()


Jun 01 2008 00:00:00 0
Jun 01 2008 07:00:00 0

Jan 01 2008 00:00:00 0
Jan 01 2008 07:00:00 0

Code:
echo date("M d Y H:i:s I ", mktime(0, 0, 0, 6, 1, 2008));
echo "<br/>";
echo gmdate("M d Y H:i:s I ", mktime(0, 0, 0, 6, 1, 2008));
echo "<br/>";
echo "<br/>";

echo date("M d Y H:i:s I ", mktime(0, 0, 0, 1, 1, 2008));
echo "<br/>";
echo gmdate("M d Y H:i:s I", mktime(0, 0, 0, 1, 1, 2008));
echo "<br/>";
 
I ran your PHP and get,

Jun 01 2008 00:00:00 1
Jun 01 2008 04:00:00 0

Jan 01 2008 00:00:00 0
Jan 01 2008 05:00:00 0


So I'm getting thr correct results ... for whatever reason. Maybe it's a server setting then.
 
I ran your PHP and get,

Jun 01 2008 00:00:00 1
Jun 01 2008 04:00:00 0

Jan 01 2008 00:00:00 0
Jan 01 2008 05:00:00 0


So I'm getting thr correct results ... for whatever reason. Maybe it's a server setting then.

Thanks I appreciate the help 😀

I get my results both on my mac and on my go daddy hosting account, im surprised they both give incorrect values.
 

yeah that works:

Code:
<?php
date_default_timezone_set('Europe/London');


echo date("M d Y H:i:s I ", mktime(0, 0, 0, 6, 1, 2008));
echo "<br/>";
echo gmdate("M d Y H:i:s I ", mktime(0, 0, 0, 6, 1, 2008));
echo "<br/>";
echo "<br/>";

echo date("M d Y H:i:s I ", mktime(0, 0, 0, 1, 1, 2008));
echo "<br/>";
echo gmdate("M d Y H:i:s I", mktime(0, 0, 0, 1, 1, 2008));
echo "<br/>";
?>


Produces

Jun 01 2008 00:00:00 1
May 31 2008 23:00:00 0

Jan 01 2008 00:00:00 0
Jan 01 2008 00:00:00 0

Thanks for your help angelwatt
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.