[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.
User avatar
twmm
Registered User
Posts: 51
Joined: Sat Nov 09, 2002 12:19 am
Location: Just Right of the Void

[FIX] Daylight Saving Time

Post by twmm »

I have been looking through all that has been written here about Daylight Saving Time and about extensive mods. I may be barking up the wrong tree, but I have been able to come up with a very simple two line MOD to phpBB 2.04 that is working for me.

In include\functions.php

Code: Select all

#
#-------[ FIND ]-----------------------------------------
# 
	return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
#
#------[ REPLACE WITH ]----------------------------------
# 
// Fix for Daylight Savings Time
    $dst = date('I', $gmepoch) * 3600;

	return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz) + $dst), $translate) : @gmdate($format, $gmepoch + (3600 * $tz) + $dst);
#
#------{ SAVE/CLOSE ALL FILES ]--------------------------
#
# EoM 
References: I would be very interested to know if this works for others as well as it does for me. Perhaps there is something that I have overlooked... so please pick it apart.

Regards,
TW
Last edited by twmm on Wed Jun 11, 2003 9:43 am, edited 2 times in total.
netclectic
Former Team Member
Posts: 4439
Joined: Wed Mar 13, 2002 3:08 pm
Location: Omnipresent
Contact:

Post by netclectic »

Trouble is, that's only going to pick whether or not the server is in DST. What about your users who are not in DST timezones?
Defend the game:
Image
User avatar
twmm
Registered User
Posts: 51
Joined: Sat Nov 09, 2002 12:19 am
Location: Just Right of the Void

Post by twmm »

Actually, it is testing to see if the dates presented to the create_date function are within Daylight Savings Time. And as you know, all the dates presented to the create_date function are GMT dates. Of course, this means almost ALL the dates used within phpBB 2.04. I have yet to find an instace that was not covered by the create_date function. Once a board's default timezone is established, it makes little difference if the users are or are not in the same timezone. What makes a difference is the consistency of date presentation based upon the board's published timezone.

Each user can be within a time zone that has "summer" time, i.e. an advancement of the time zone. For example, in the Western European Time zone they have "summer" time with an advancement of one hour, but not within the same calendar dates as the US and Canada. As another example in Australia, there are time zones that advance .5 hour (half an hour) during the summer, as well as some areas within a time zone that do not advance at all during the summer, much like parts of Indiana.

So again, whatever a user selects as their profile time zone will affect how they see the board times. But if the board times advance refelective of the time zone selected by the board adminstrator, the user will still see times relative to the time zone for which they have selected.

I cannot see an easy way of handling times for all people within all time zones. The time zone issue is too geographical, too geopolitical, and too socio-economic.

Regards,
TW
User avatar
TommyV
Registered User
Posts: 45
Joined: Wed Oct 23, 2002 10:42 am
Location: Fredericia, Denmark
Name: Tommy
Contact:

Re: [FIX] Daylight Savings Time

Post by TommyV »

twmm wrote: I have been looking through all that has been written here about Daylight Savings Time and about extensive mods. I may be barking up the wrong tree, but I have been able to come up with a very simple two line MOD to phpBB 2.04 that is working for me.

In include\functions.php

Code: Select all

#
#-------[ FIND ]-----------------------------------------
# 
	return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
#
#------[ REPLACE WITH ]----------------------------------
# 
// Fix for Daylight Savings Time
    $dst = date('I', $gmepoch) * 3600;

	return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz) + $dst), $translate) : @gmdate($format, $gmepoch + (3600 * $tz) + $dst);
#
#------{ SAVE/CLOSE ALL FILES ]--------------------------
#
# EoM 
Reference: http://www.php.net/manual/en/function.date.php

I would be very interested to know if this works for others as well as it does for me. Perhaps there is something that I have overlooked... so please pick it apart.

Regards,
TW


I had the same problem, and I have just implemented the above code. And it looks like it works :-)

/Tommy
User avatar
twmm
Registered User
Posts: 51
Joined: Sat Nov 09, 2002 12:19 am
Location: Just Right of the Void

Post by twmm »

Thanks.

I have been using the code going on two months now, and I have no complaints. Also I have found no reason to make additional changes.

Regards,
TW
User avatar
Numlock2KS
Registered User
Posts: 84
Joined: Fri May 23, 2003 7:17 am
Contact:

Us this a User Controlled Option?

Post by Numlock2KS »

Hello,

Does this provide an 'on/off' function during user configuration for Daylingt Savings Time?

It appears that two variables would be required...

First variable: Is daylight savings time used? Yes (on) or No (off) [Variable Name: DST_USE] User Configurable
Second variable: Is date within activated daylight savings time range? Yes (on) No (off) Variable Name: [DST_ACT] Admin Configurable Only - Range set by Admin, directly within script, or by database engine.

With these two variables entered it would be possible to use a simple query to update user times for Daylingt Savings Time.

I believe that all of the database platforms that phpBB operates under offer the function for the [DST_ACT] information. This leaves only the question about the user's wish to use it. This is why I ask if this this is a user-controlled option. Telling the server that the system uses Daylight Savings Time provides only one of two required fields.

I must also say that I am a bit surprised that this function is not included in the phpBB distribution files. Perhaps it will be included in the next release? *Hope**Hope*

Thank You
User avatar
twmm
Registered User
Posts: 51
Joined: Sat Nov 09, 2002 12:19 am
Location: Just Right of the Void

Post by twmm »

Hello -

I am not sure I understand your question; but perhaps, you misunderstand how this is used. I think if you follow the link (hopefully you have a grasp of php) to:

http://www.php.net/manual/en/function.date.php

you will come to understand that it is the server's knowledge of Daylight Savings Time (summer time) that is being tested. Postulating that you need to control the display of the times of your postings as they are effected by Daylaght Savings Time, you would use this fix. In orther words, if your server is in a country/location that does not observe Daylight Savings time, your times would not change.

Once again, user's time zones are irrelevant. Hypothetically, if you (your forums) are located in Paris, France, the only relevant time is the correct time in Paris, France, as displayed in your forums. The individual user can adjust his profile preferences to reflect (for him and him alone) his local time in San Francisco, CA, USA, or wherever else he is located.

Regards,
TW.
User avatar
Rancisis
Registered User
Posts: 161
Joined: Sun Dec 08, 2002 10:57 am
Location: Belgium

Post by Rancisis »

Works like a charm, thanks dude :D
User avatar
Carpe Diem
Registered User
Posts: 580
Joined: Tue Dec 10, 2002 11:19 pm

Post by Carpe Diem »

Well thank you very much for this fix, works great.
:D
inque187
Registered User
Posts: 94
Joined: Sat Jun 29, 2002 9:17 am
Contact:

Post by inque187 »

Thanks A Million for this mod/fix. The time was driving me crazy and I spent 30 minutes searching the phpBB forums for this.

Raise Up!!!!! Thanks! :lol:
jeep
Registered User
Posts: 93
Joined: Mon May 19, 2003 8:57 pm

Post by jeep »

Won't this just invert the problem? So users NOT in places that observe daylight savings time wil lhave to adjust their timezones instead of those who are in places with DST?

Sorry, I'm asking the same question as others, but I don't understand how this will fix the problem.

My server is in a place with daylight savings time. So this "fix" will alter times. I am in a place with Daylight savings time. (We'll use the West coast of the USA, since that is indeed where I am)

I make a post
2003 Oct 26 01:55:00 PDT

Then 10 minutes later I make a post at
2003 Oct 26 01:05:00 PST

What dates will my posts show up as posted when I view my posts (I'd be in PST)?
I should see them as
Oct 26, 2003 12:55 PST
Oct 26, 2003 01:55 PST

If they are viewed by a user in Arizona (which is one hour ahead during Standard Time and doesn't have daylight savings time) what times will they see them as posted? They should see them as:
Oct 26, 2003 01:55:00 CST
Oct 26, 2003 02:05:00 CST

Is that what will happen? Or will the folks in AZ see them an hour off since they don't observe DST? It seems to me like they will see them an hour off.

-JEEP
User avatar
Rancisis
Registered User
Posts: 161
Joined: Sun Dec 08, 2002 10:57 am
Location: Belgium

Post by Rancisis »

If I understand it correctly, the code goes watch the server time to see if it's DST or not.
If it is, it ads an hour to the date you see.
And all users can still say in their profile what GMT they have.

So it should be something like this:
DST GMT: Sat May 31, 2003 9:21 pm
DST GMT +1: Sat May 31, 2003 10:21 pm
GMT: Sat May 31, 2003 8:21 pm
GMT +1: Sat May 31, 2003 9:21 pm

At least, I think it's like that.
Could be it substracts an hour too :-/
Anyway, it works so be happy...
jeep
Registered User
Posts: 93
Joined: Mon May 19, 2003 8:57 pm

Post by jeep »

Actually, it doesn't appear to work... It works great if both the user and the server are in places that have DST. For other users, it still requires them to change their timezone when the time changes.

-JEEP
LucidParody
Registered User
Posts: 208
Joined: Thu Oct 24, 2002 8:15 am
Contact:

Post by LucidParody »

it doesnt do anything for me :(
inque187
Registered User
Posts: 94
Joined: Sat Jun 29, 2002 9:17 am
Contact:

Post by inque187 »

:cry: ok, I think i may have spoke to soon.

:roll: I installed this fix and I am still having the same issues. Everytime when a person logs in and sets the timezone in their profile (namely myself) the time shows as 12 hours ahead of the set time in profile. Sometimes it will fix itself but I assure you that the server time is correct.

:?: Any ideas?
Locked

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