[FIX] Daylight Saving Time

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
maoren99
Registered User
Posts: 3
Joined: Wed Jun 30, 2004 9:49 pm

Post by maoren99 »

I've tried this fix on my site but it didn't work. To me this fix is simple enough to understand, and I believe the date() function does not work well on my server, it always returns 0 in case it should return a 1. :evil:
Any way to fix this? Or I have to write my own code to determine if the date is in DST?
User avatar
defender-uk
Registered User
Posts: 380
Joined: Tue Jun 01, 2004 9:06 am
Location: London, UK
Contact:

Post by defender-uk »

Thanks for the Mod.

Works a treat :)
Furious George
Registered User
Posts: 50
Joined: Wed Sep 04, 2002 3:28 pm
Location: tx
Contact:

Post by Furious George »

this seem to work up until summers soltice. i modded the board like it said in page 1 and it fixed the problem. but ever since "fall back" the times have been off by an hour. any suggestions?
ethos
Registered User
Posts: 3
Joined: Mon Jul 26, 2004 8:26 am

Post by ethos »

Isn't there a really simple solution to this: why can't PHPBB simply adjust it's times based on the users system clock? If that were the case, no user configurable time zone would be necessary at all- a mod should be made to keep track of all time based on the servers time. Then, when the user logs in PHPBB checks the users time and says:

timeOffset = userTime - serverTime

then the board simply applies the time offset to all of it's stored times, for example:

postTimeDisplay = postTime + timeOffset

This solution may require a lot of recoding and I'm not a PHP programmer so I don't know exactly how it would be coded, but it seems like it would be an iron-clad solution that would stand the test of time (no pun intended). Of course, this solution is based on the idea that PHP has the capability of retrieving a user's system time. I sure hope it does, but if not, perhaps other technologies could be implemented with PHP that can. Anyway, I would LOVE to see this issue resolved, since it is such a stupid nuance. Thanks!

Ethos
nodemaster
Registered User
Posts: 4
Joined: Thu Oct 21, 2004 9:00 pm
Location: Jacksonville, NC
Contact:

Just what the doctor ordered!

Post by nodemaster »

Out of all of the challenges that my forum users have posed to me...this one was starting to get to me.

...funny thing is, it was probablly one of the simplest fixes that i've implemented.

Thanks for a great piece of code!
Brian Norris
Network Administrator

"Judge a man by his questions rather than his answers." -Voltaire
ethos
Registered User
Posts: 3
Joined: Mon Jul 26, 2004 8:26 am

Post by ethos »

Has anyone tried coding my suggestion yet? If so, could you copy and paste the steps you took here. Is it possible? If so, I think it is a perfect solution. Any loopholes? Problems?

Ethos
User avatar
Brenakie
Registered User
Posts: 77
Joined: Mon Mar 15, 2004 12:08 am
Location: Pascoag, RI - USA
Contact:

Post by Brenakie »

I just added the MOD and everything seems to be working OK wish I found it b4 we went to 10/31 :wink:

Brenakie -5 :lol:
Rickshaw
Registered User
Posts: 2
Joined: Sat Dec 04, 2004 5:47 am

PHP date() function

Post by Rickshaw »

I'm not clear how twmm's mod works. It depends on the 'I' format specifier to PHP's date() function to get daylight savings time info:

$dst = date('I', $gmepoch)

According to the PHP docs, this returns whether or not $gmepoch is in daylight savings time: 1 if daylight savings time, 0 otherwise. Note this is different than whether the current time is in daylight savings time!

Trouble is, the docs don't explain how date() decides if a given timestamp is in daylight savings time. DST starts and ends on different dates in different political regions of the world. Does it use the DST rules for the United States? Does it matter whether or not the server is itself located in a region that observes daylight savings time?
Rickshaw
Registered User
Posts: 2
Joined: Sat Dec 04, 2004 5:47 am

explanation of daylight saving fix

Post by Rickshaw »

OK, I've done a lot of research into this now, and I believe I can explain how twmm's one-line fix works, since this seems to have confused a lot of people and wasn't explained very clearly. I believe that the fix does basically work, with a few minor problems.

This fix alters the way timestamps are written as text. It does not affect the timestamps themselves, or the posts in your database. It is purely a visual display change.

It uses the server's OS information about the DST rules, so you'll get different behavior depending where your server is located. In the US, it will follow US DST rules. In other locations, it will follow the local rules for DST, assuming the server's timezone info is configured correctly. For a server in a location that does not observe DST, the fix will do nothing at all.

For all timestamps that are within the DST range, 1 hour is added to the timestamp when converting it to text. Note that the decision is based on the stored timestamp, not the current time. This is important when viewing an old topic from January during July.

If all your board's users follow the same DST rules as the server themselves, then they'll see their times adjusted automatically, and everyone will be happy. So if your board is primarily of local or national scope, this will probably be fine. But for any user who follows different DST rules or does not observe DST at all, their times will be adjusted incorrectly, and they will be confused and annoyed. It's probably best to add an option in the user control panel to let people choose whether their time display should be adjusted.

One other problem is that the text "All Times are GMT - 8 hours" will not be changed, even though it's no longer correct. Changing the hour in that text by 1 isn't correct either. The reason is that all times are no longer displayed in any single GMT offset, but instead use different offsets depending on the date of the post. You could maybe change it to say something like "All Times are GMT - 8 hours (winter) / GMT - 7 hours (summer)", or use the common timezone name like "All Times are Pacific Time".

One last note: the often-repeated suggestion about changing everyone's timezone setting for DST is not just cumbersome, it's also plain wrong. It will cause the time to be displayed correctly on recent topics, but if you go back and read a topic from six months ago, all the times will have changed by one hour. You cannot correctly compensate for DST with a simple timezone change.
aXeR
Registered User
Posts: 22
Joined: Tue Nov 16, 2004 1:21 pm

Post by aXeR »

Many thanks twmm, been pulling my hair out for hours over this and now its fixed :D

Great job!
big_ben
Registered User
Posts: 9
Joined: Mon Apr 05, 2004 11:32 am
Location: Les Gets - FR

Post by big_ben »

Thx a lot for this mod! works fine in FR too ;-)

I was fed up to update manually user_timezone +1 or -1 (what is false, but helps when nothing better).
samivaan
Registered User
Posts: 13
Joined: Wed Mar 31, 2004 7:39 am

Post by samivaan »

edit: cleared message. Problem fixed.
wkitty42
Registered User
Posts: 191
Joined: Sat Apr 03, 2004 1:11 pm
Location: Central North Carolina, USA
Contact:

Post by wkitty42 »

one thing that i'm confused about WRT this mod... here are my details...
  1. my server is on the US east coast...
  2. my server's time does change when DST starts and stops...
  3. my phpBB is set to GMT-5 in the ACP...
  4. the DST stuff is fixing to change this weekend...
my question is: do i need to change the ACP setting to GMT-4 when the change occurs or just leave it alone?? i think i should leave it alone but would like to be sure...

as i understand it, the opposite side of the coin is that users who used to change their setting from GMT-5 to GMT-4 should not do that any more since i've applied this fix??

i've read the entire thread and got more confused about ABC, XYZ and PDQ as i read... i believe the idea is to keep the timestamps in the database the same... that is, keep them being stored as UTC even though the server's clock jumps back and forth twice a year... i'm just not sure if the ACP setting needs to be changed or if my members should still change their profile setting... [yes, that's two questions ;)]
wkitty42
Registered User
Posts: 191
Joined: Sat Apr 03, 2004 1:11 pm
Location: Central North Carolina, USA
Contact:

Post by wkitty42 »

hello?

is there anyone who has /the/ answers to those two questions?

where is twmm? is he no longer on with us? his last post on this site was in this forum last year sometime :(

hello? :? :?
User avatar
jkloska
Registered User
Posts: 41
Joined: Thu Dec 16, 2004 5:11 am
Location: Chicago, IL
Contact:

Post by jkloska »

Well. I used this mod some time ago and have been anxiously awaiting DST, since I was too lazy to test it, having many other things to worry about :cry:

Anyway, I am pleased to see that the mod works well. I think many of our fears are needless. Yes, no more manual changings of the time zone at DST, and this is a good thing.

Can't speak for twmm, but from all the misunderstandings, and patient re-explainings of this mod I would have gotten tired of it long ago.

I say the mod is well done. Is it perfect? I don't think anything in this area can be, but this seems to do the job pretty well. AND... I am thankful that this mod exists! :D
Locked

Return to “[2.0.x] MODs in Development”