Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/57828?pagenum=1
05 November 2025, 08:47
Topic
MarkJH
Timezone MOD
03 April 2005, 07:48
Every other forum software I know has a section in the user's profile where they can change the time displayed to match their timezone. Now, isn't it about time that we had something like this for Snitz?
It would be just a dropdown box in the profile that gave a -12/+12 from GMT (or whatever) and when the clocks went back or forth it would be completely down to the user to adjust the time in their profile.
That's all it needs. No complicated equations to calculate daylight savings etc.
Please tell me if I'm over-simplifying things. <
Replies ...
ruirib
03 April 2005, 10:38
It has been done, since that was available for the beta of the upcoming version of Snitz. DOn't know whether it is available as an independent mod, though.<
-gary
03 April 2005, 12:35
I posted a simple solution a while back, but evertime I try and search the archives it times out so I can't give you a link. It wasn't a mod though since the collecting and storing of the users zone was up to you. I only gave the code for adjusting the displayed time which is trivial.<
MarkJH
03 April 2005, 13:20
DOn't know whether it is available as an independent mod, though.
I haven't seen it. The only thing I've found is what Bozden was working on for version 4. That was two years ago.
Gary, I'd love to see your code... if it can be found! I don't think it would be too difficult to work with that and a dropdown in the profile to make a working MOD.<
laser
03 April 2005, 16:53
In Image's forum there is a timezone feature, so the mod for that must be floating around somewhere.<
HuwR
03 April 2005, 17:15
The code was written by me, but was never released as a MOD, mainly because it involved a lot of core code changes and was a bit quirky on some servers.<
-gary
03 April 2005, 18:54
Store the users time zone in the strM_TIMEZONE variable. Set the "Time Adjustment" setting in the admin panel to the inverse of your time zone to bring the server to GMT. Add the code below to the chkDate function in inc_func_common.asp.
The hardest part is modifying the profile pages to store the users time zone.
if fDate <> "" and strM_TIMEZONE <> "" Then fDate = DateToStr(DateAdd("h", strM_TIMEZONE, strToDate(fDate))) End if<
MarkJH
03 April 2005, 19:16
The code was written by me, but was never released as a MOD, mainly because it involved a lot of core code changes and was a bit quirky on some servers.
But wasn't your code a lot more complicated than that? Didn't it take into account daylight saving adjustments around the world? I'm just looking for something that leaves all of that down to the user. If the clocks go forward or back, they make the adjustment.
Thanks for supplying the code, Gary. Would somebody have a way of incorporating that into the user profile?<
cripto9t
04 April 2005, 11:26
Mark, after seeing the earlier thread on this, I Used Garys suggestions and got this working. I used Invision Board(log-in - demo, demo) as a model, in fact the select box I use is Invision Boards .
As Gary said the server/forum time is set to GMT (I did play around with this and found it to be best). Then members adjust time in thier profile, there is an adjustment for DST.
I never released it as a mod because I wasn't to sure of it. But it has passed all my testing so far. If your interested in testing it I will get the code together.
<
MarkJH
04 April 2005, 14:39
Looks good, Cripto.
My only concern with this MOD is the DST bit. My server is based in the US. The clocks went forward one week earlier in the UK than in the US. Wouldn't this cause problems?<
laser
04 April 2005, 17:39
Yep, Aussie DST works a few weeks diff to USA DST, NZ DST changes are different again, then some timezones do not have DST at all ..... just remind the users to do the old +/- 1 when they need to.<
withanhdammit
04 April 2005, 23:07
I'd also be interested in a timezone mod like this!
h<
sr_erick
05 April 2005, 02:02
Hmm, I just tossed together some code a few months ago so users could adjust the time. Like everyone else, not an official mod but it did the trick for me. I have to add the daylight savings time checkbox though, which is the only thing I am missing.<
cripto9t
05 April 2005, 08:00
..... just remind the users to do the old +/- 1 when they need to.
Thats what I'd do. Like the message says, it's up to you to keep your profile up to date .
sr_erick, I'd be interested in seeing what you've done.
I'll try to get this together today.<
cripto9t
06 April 2005, 10:54
I think I got it all right click and save.
I put a small readme in the zip. Word of caution, if you try this, all previous posts will be off up to +/- 12 hrs. Depending on the difference in the new and old settings. Also, if you remove it, the same thing applies to posts made while this was in use.
If your forum is already set to GMT there shouldn't be no problem .
Like I've said, I haven't really been able to test this good so you should be willing to take a risk . I think the worst it could do is screw up a few post times if you don't like it.<
MarkJH
06 April 2005, 12:25
Great stuff! I'll give this a try at the weekend and let you know how I got on. <
MarkJH
08 April 2005, 16:47
Hmm, I've added all of the code as required but for some reason, when I change the timezone in my profile, it doesn't make the times in the forum reflect the change. Is there something missing?<
cripto9t
09 April 2005, 07:19
I figured I'd miss something .
The important part.
In "inc_func_common.asp" find this
Code:
function chkDate(fDate,separator,fTime) if fDate = "" or isNull(fDate) then if fTime then chkTime(fDate) end if exit function end if
if (strMemberTimeAdjust = "1" and strDBNTUserName <> "") then if (strTempScript <> "admin_config_datetime.asp" and strTempScript <> "pop_profile.asp") then '## If you have a file that you dont time adjustment, add it to line above ### strSql = "SELECT M_TIME_ADJUST, M_DST_ADJUST" strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS" strSql = strSql & " WHERE M_NAME = '" & strDBNTUserName & "'"
set rsMemTime = Server.CreateObject("ADODB.Recordset") rsMemTime.open strSql, my_Conn
if rsMemTime.bof or rsMemTime.eof then rsMemTime.close set rsMemTime = nothing else if rsMemTime("M_TIME_ADJUST") = 0 or isnull(rsMemTime("M_TIME_ADJUST")) then '## Do Nothing else mTimeAdjust = cSng(rsMemTime("M_TIME_ADJUST"))
if cLng(rsMemtime("M_DST_ADJUST")) = 1 then mTimeAdjust = mTimeAdjust + 1 end if
if InStr(mTimeAdjust,".") then if InStr(mTimeAdjust,"-") then intHalfHour = -30 else intHalfHour = 30 end if strAdjustfDate = DateAdd("n",intHalfHour,strAdjustfDate) end if
fDate = DateToStr(strAdjustfDate) end if rsMemTime.close set rsMemTime = nothing end if end if end if
Looking at this, I think I'll try something different. I'll let you know if I come up with something.<
MarkJH
09 April 2005, 07:45
Seems to work like a charm. You should wrap this one up as a working MOD. Really nice work, Cripto. Been waiting for something like this for years!<
chazzer
21 April 2005, 10:08
Cripto-
Agreed. Nice work! It works like a charm!
One word of warning to others... The inc_func_common.asp file may in some cases be referenced in other places off the board. For instance, we display hot topic headlines on the front page of our site... when I applied the updated inc_func_common, the front page started throwing a subscript out of range error [approx line 588 --> strTempScript = arrTempScript(Ubound(arrTempScript))]... Same things happened on my RSS feed page which references the same include.
My workaround was simply to create a different inc_func_common with a different name, and minus the tweaked code... Pointed my homepage and my RSS page to the "old" include, and it all works like a charm now.
There may have been a better way to accomplish that, but that seems easy enough!<
MarkJH
21 April 2005, 12:49
That's funny. I noticed the same error within my Announcement MOD just yesterday.
---
Microsoft VBScript runtime error '800a0009'
Subscript out of range: 'UBound(...)'
/forum/inc_func_common.asp, line 1021
---
I fixed it by changing the line above it (in red) from:
Code:
if fDate = "" or isNull(fDate) then if fTime then chkTime(fDate) end if exit function end if arrTempScript = Split(strScriptName, "/")
strTempScript = arrTempScript(Ubound(arrTempScript)) strTempScript = lcase(strTempScript)
to this:
Code:
if fDate = "" or isNull(fDate) then if fTime then chkTime(fDate) end if exit function end if arrTempScript = split(request.servervariables("SCRIPT_NAME"),"/")
strTempScript = arrTempScript(Ubound(arrTempScript)) strTempScript = lcase(strTempScript)
This was a bit of an semi-educated guess as a search on these forums for the same error brought up a post to do with an unrelated MOD but the fix was similar.
Somebody who knows what they are doing should probably take a look!<
chazzer
21 April 2005, 13:25
Interesting.
I was trying to figure out what that line of code was doing, and couldn't figure it out... Sounds like you have a better idea of what's going on... What does that line do?<
MarkJH
21 April 2005, 15:06
I made a search for the error message and this was the only thing that came up. Even though it was for a different MOD, I copied across the code and everything seems to be working.
I have no idea what it does, but it's working! <
cripto9t
22 April 2005, 07:52
Look at the top of "inc_header", you'll find strScriptName.
If a page uses this function and don't include "inc_header" you will get the error.
What it's does is get the page name e.g. this page is "topic.asp". I have it in there to bypass pages that don't need the member time adjustment.
Chazzer, you should go with Marks fix, so members will have the time adjusted on your homepage. If you guys have a page that doesn't need the time adjustment, add it to this line.
Code:
if (strTempScript <> "admin_config_datetime.asp" and strTempScript <> "pop_profile.asp") then
I think I put a note beside it .
I updated the zip with Marks changes, so other folks won't have the same problem . Thanks guys.
<
MarkJH
22 April 2005, 12:00
Thanks for the clarification. <
chazzer
28 April 2005, 10:25
Yeh, I am using Mark's fix... It certainly seems much cleaner than creating a different inc file... And everything looks fine... Although on our home page most folks who see that aren't registered on our board... So there I am just using GMT. Since we have folks from all over the world using the site, that makes the most sense anyway...
Thanks for the mod and the help!
<
Just noticed the same problem on my own site.
Does anybody know why this is occuring?<
HuwR
04 January 2007, 14:10
the dropdown is populated from the database If I remember correctly.<
Max0005
05 January 2007, 02:32
Originally posted by ruirib It has been done, since that was available for the beta of the upcoming version of Snitz. DOn't know whether it is available as an independent mod, though.
Where can i download it!?<
MarkJH
16 January 2007, 18:47
Does anybody know why this is occuring?
Any idea, cripto9t?<
MarkJH
21 January 2007, 13:38
I think I have an idea on how to fix this. In cripto's zip file, there were no changes made to register.asp. Maybe the changes made to pop_profile.asp should be made to register.asp?<
Rob Alan
21 January 2007, 22:51
MarkJH
27 January 2007, 07:54
Works great Rob but it doesn't show the Daylight Savings box on register.asp. Got a fix for that?
Also, have you tested this to make sure it 'sticks' for a newly registered user?<
cripto9t
27 January 2007, 19:13
Sorry its taken me so long to reply guys. I think I fixed it. It's the ChkSelect2 function causing the problem.
Replace this code
Code:
for iTimeAdjust = 0 to ubound(intTimeAdjust) Response.Write " <option value=""" & intTimeAdjust(iTimeAdjust) & """ " & ChkSelect2(rs("M_TIME_ADJUST"),intTimeAdjust(iTimeAdjust)) & ">" & txtTime(iTimeAdjust) & "</option>" & vbNewLine next
With this
Code:
for iTimeAdjust = 0 to ubound(intTimeAdjust) Response.Write " <option value=""" & intTimeAdjust(iTimeAdjust) & """" if strMode = "Register" then if iTimeAdjust = "13" then response.Write "selected" else Response.Write ChkSelect2(rs("M_TIME_ADJUST"),intTimeAdjust(iTimeAdjust)) end if Response.Write ">" & txtTime(iTimeAdjust) & "</option>" & vbNewLine next
Let me know how it works out<
MarkJH
28 January 2007, 11:01
Seems to work fine, Cripto. Still doesn't show the Daylight Savings box on register.asp, though.<
cripto9t
02 February 2007, 07:42
hmmm... Like the chkSelect function the chkCheckbox function depends on a value from the members table that doesn't exist if your registering.
So if I check strMode... I'll be back<
cripto9t
02 February 2007, 10:03
Mark I got the dst box fixed. Also I had to make some changes to "register.asp" because the inputs weren't "sticking" as you said.
I'm not going to post the changes here. Just download the zip file again.
Make the change I marked in "inc_profile.asp" and make the 4 changes in "register.asp".
Let me know how it goes.<
MarkJH
02 February 2007, 16:41
Installed and working great. Good work!
I do have a slight problem though, and it's nothing to do with your MOD but something that maybe would be easy to fix...
I have the following code installed in inc_func_common.asp from kwhipp's Today/Yesterday MOD.
Code:
select case Mid(Request.ServerVariables("SCRIPT_NAME"), InstrRev(Request.ServerVariables("SCRIPT_NAME"), "/")+1) case "admin_accounts_pending.asp", _ "admin_config_datetime.asp", _ "pop_printer_friendly.asp" ' ' For any page that needs the actual date, add the file name to the above case statement.
' case else select case left(fDate,8) case left(DateToStr(date),8) chkDate = "Today" case left(DateToStr(date-1),8) chkDate = "Yesterday" end select end select if fTime then chkDate = chkDate & separator & chkTime(fDate) end if
The code just replaces today's and yesterday's dates with the words "Today" and "Yesterday". Thing is, it doesn't follow the Timezone time rules and at midnight, when today becomes yesterday, instead, yesterday remains "Today" and today just has a date. I hope that made sense... Can you see in the code how this could be fixed?
If you can do this, maybe along with kwhipp's code, this would be great all wrapped up in a fully working MOD Add-On Forum (W/Code)/Snitzbitz MOD. <
cripto9t
04 February 2007, 15:14
I'll give it a look Mark.<
MarkJH
04 February 2007, 18:18
Thanks. <
MarkJH
06 February 2007, 18:33
Anything on this, Cripto? I know you're busy with the quiz MOD but I was just wondering if you'd taken a look at the code.<
MarkJH
11 February 2007, 11:04
I don't think that registration works with your changes, Cripto.
Just tried to register and got this error:
Code:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Invalid column name 'M_TIME_ADJUST'.
/forum/register.asp, line 804
I'll have to remove the code for the time being. <
I'm hoping you had e-mail validation turned on when you got the error and that this will fix it.
I finally got a day off today and I'll give the yesterday/today thing a look.
<
cripto9t
13 February 2007, 11:49
Mark, I threw this together and it seems to be working pretty good for the today part.
I don't have post to check the yesterday part.
It's more of a hack than anything. It basically hijacks the chkDate() function if the last post is less than 2 days old.
I thought I had kwhipps mod down somewhere but I couldn't find it.
I did find some of my old stuff that converts last post to a "1 hr 2 mins ago" like format, if your interested.
in the time adjust code in inc_func_common.asp
right after these lines
Code:
rsMemTime.close set rsMemTime = nothing end if
Add this
Code:
'yesterday/today hack pt. 1 strUserFriendlyDate = true '$$ on/off switch - true for on / false for off
if strUserFriendlyDate then if chkUFD(fDate) = 1 then if trim(getUFD(fDate,fTime)) <> "" then chkDate = getUFD(fDate,fTime) exit function end if end if end if
'$$ end pt 1
And right after the chkDate() function add this
Code:
'$$ yesterday/today hack pt. 2 function chkUFD(fDate) dim tmpDate
tmpDate = StrToDate(fDate)
if DateDiff("d",tmpDate,Date) < 2 then chkUFD = 1 else chkUFD = 0 end if end function
function getUFD(fDate,fTime) dim thisDate,tmpDate
thisDate = StrToDate(fDate) tmpDate = "" if DateDiff("d",thisDate,Date) = 0 then tmpDate = tmpDate & "Today" elseif DateDiff("d",thisDate,Date) = 1 then tmpDate = tmpDate & "Yesterday" end if
if fTime then tmpDate = tmpDate & " at " & chkTime(fDate) end if
getUFD = tmpDate end function
'$$ end pt. 2
<
MarkJH
22 February 2007, 13:29
Sorry about the late reply. I've been too busy to have a good look and test of this.
Right...
Run this through mod set up
[ALTER]
MEMBERS_PENDING ADD#M_TIME_ADJUST#varchar(4)##0 ADD#M_DST_ADJUST#smallint##0 [END]
I'm hoping you had e-mail validation turned on when you got the error and that this will fix it.
It fixed it good. Created a test account, changed the time to -1 GMT in my registration profile, logged on... -1 GMT. Excellent! As to your today/yesterday fix, I found another way of doing it which is much simpler and kept the formatting intact - here. Haven't tested whether or not it works past midnight okay but I'll see tonight.
Thanks for all the work you've done with this, Cripto9t. Hopefully, that's all the bugs ironed out now. <
MarkJH
22 February 2007, 19:20
Haven't tested whether or not it works past midnight okay but I'll see tonight.
Passed. <
lovduv
26 March 2007, 22:50
Ok call me stupid, but I am confused. I installed this and it is working.
However, I am not setting things correctly: The server time is EST, which is what I had it set on before, with correct time.
I now have it set to GMT 0:00 (London, etc.), which shows the time for EST, and when I adjust my timezone to EST in my profile it sets it to GMT -5:00.
So what settings do I need, so that my members can adjust the post times to their time zone? Server is in the EST timezone and so am I.<