Jump to content
Updating IPB tonight Read more... ×


This topic is now archived and is closed to further replies.


date() function and DST

Recommended Posts

Hi guys

Need help with the daylight saving time (DST). Have been tearing my hair out over this for the past hour.

I need PHP to follow the UK timezone, and have therefore added the following line at the start:

For those who don't already know, the official timezone for London is GMT. As DST is observed in london now, time should be 1 hour forward from GMT i.e. GMT +01:00

PHP's date function can "detect" the DST correctly; date('I') returns 1.

echo "London<br>";
echo "Timestamp: ".time()."<br>";
echo "DST: ".date('I')."<br>";
echo "Time: ".date('H:i O')."<br>";
echo "<br>";
echo "GMT<br>";
echo "Timestamp: ".gmmktime(date('G'), date('i'), date('s'), date('n'), date('t'), date('Y'))."<br>";
echo "DST: ".gmdate('I')."<br>";
echo "Time: ".gmdate('H:i O')."<br>";

Timestamp: 1150213911
DST: 1
Time: 15:51 +0100

Timestamp: 1151686311
DST: 0
Time: 15:51 +0000[/code]

I am totally confused by the output. I would think that London's time would output 16:51 instead.

Does PHP support fully support DST? Or do I not understand DST enough?


Share this post

Link to post
Share on other sites
Running the code you have above I got this output:
[code] London
Timestamp: 1150236686
DST: 1
Time: 23:11 +0100

Timestamp: 1151709086
DST: 0
Time: 22:11 +0000[/code]
Is this not what you want it to show?

Share this post

Link to post
Share on other sites
Yes. That's what I want it to show. Problem is, my server is in Singapore where there isn't DST.

maybe putenv is not the best method..

any help here?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.