Wow, the Blog Post Timestamp drives me crazy. I'm in Germany (Timezone CET, +1) and my server is located in (PST, -8). In Date/Time Settings, timezone is set to the servrs timezone and in the users profiles, timezone is set to the local (CET) timezone. In a default installation of CommunityServer 2006 the behaviour is as follows.
(Assuming the writing and reading users have Timezone CET, +1 set)
- I write a post at 12 pm (CET)
- Posts table in database: PostDate = 3 am / UserTime = 12 pm (ok, so far)
- I am logged in and i read the posting, i see the posting timestamp is 9 pm. Ough, that's in the future. Bad stuff.
I figured out that i have to change all of the themes (post.aspx, postlist.aspx and taglist.aspx) to use PostDate instead of UserTime. That works so far. As a logged in user i see the correct posting timestamp of 12 pm.
Next problem: I want the anonymous users to see the timestamp according to my CET timezone. Quick try unveils that anonymous users always get the server time (PST). I changed the web.config in a way that the timezone default value in the profile definition is "1" which means CET. Does not work. Still PST times for anonymous users.
My next thought: Oh, we have a user "Anonymous" in the membership. Would be nice if i could define the default timezone of anonymous users in the profile of the user named "Anonymous". I set his timezone to +1 (CET). Hmpf, does not work. Still the PST times.
As i figured out, the problem is in User.cs, Method GetTimezone(DateTime date, bool isUTC) where Timezone calculation is skipped for anonymous users:
if (IsAnonymous) return tmpDate; return tmpDate.AddHours(Profile.Timezone - CSContext.Current.SiteSettings.TimezoneOffset);
Why that? Is there any good reason to do so. I want timezone calculation even for anonymous users! (You can take that as a change request for the next release.)
So, how to get CET timestamps for anonymous users??? Any good ideas?
Next problem: I always get the timestamps in 12-hour format. Iwnat them in 24-hour format. The Parameter in Date/Time Settings has no effect, at least in blog postings. In most of the themes, there is a Format of hh:mm... hardcoded. Sounds like i have to change all the themes once more, right?
All in all, the timezone handling in CS (at least for blogs) is -beep- (i want to say the word with the B and the S but i assume that is on the blacklist ) and must be strongly revised.
Summary:
I'm surprised that nobody, especially from Telligent, has answered this post.
I'm having the same problems even after many tests and double checks of my settings, I can't get something reliable. There is even a difference of time between forums posts and posts blogs. Here is my last test:
I'm in France, my local is GMT+1 (with daylight savings, that gives GMT+2 at this time), my user profile is set to GMT+1.
My web and database servers are in Arizona (Crystaltech), which is MST (GMT-7).
I write a blog post at 10:20 PM, on July 31 (that's 1:20 PM on July 1 in Arizona). This post appears for me as being posted on August 1 at 9:20 AM (!!!) and of course, I won't be able to see it before tomorrow morning .
One minute later , I write a forum post. My local time in France is 10:21 PM, July 31. It appears as beeing posted at 9:21 PM July 31.
That is :
1 - Inconsistent2 - Really annoying
Conclusion: host your CS site in the same time zone as where most of your users live or choose another community solution.
Telligent, do you have another solution?
Thank you.
Same here, servers are in GMT-5, I am in GMT+1 and want the server to behave as if its located in GMT+1.
So Telligent, what about an anwser from your side?
Thanks in advance!
Additional questions.
Why is it that CSBlog:WeblogPostData switches between PostDate and UserTime when loging on and off?
Why are you not saving the UTC DateTime to the database, wouldn't that prevented these problems?
Please help us!
I also found that User.GetTimezone adds hours also to DateTime objects that are already correct.
Example:
In the default theme the following code prints the time (GMT+1 due to my profile setting) on which I wrote the post underneith each post.
<
For the anonymous user this works but as soon as I logon *** happens in the User class:
tmpDate.AddHours(Profile.Timezone - CSContext.Current.SiteSettings.TimezoneOffset);
My server is in GMT-5 so this line results in 6 hours being added to an already correct DateTime.
I also noticed that anonymous comments are added with UserTime and PostData set to DateTime.Now, which imo is incorrect.
I believe UserTime should be set to DateTime.Now.AddHours( timezone setting in web.config )
You should really save all dates as UTC/GMT and let the profile settings determine the value displayed.
Please change it!!!
For the timezone differences on the posts...Have you tried going into the control panel's date / time settings, and setting your default value there?
Ryhoward.com - Community Server from the Support Side of things. Technical tips and ideas for CS users.
Hi, thanks for your reply!
The date/time setting is set to the timezone in which the database server resides (GMT-5 in my case). That is what is should be set to, right?
Yes, there is that setting in the control panel for the site itself, then there is the option to set the time zone per user on each user's profile. Is that not working for you?
No, unfortunately it is not working for me.
My settings are as follows:
Now, when I am logged on and create a blog post, the control panel's "All Posts" overview shows the GMT+1 DateTime. (Correct)
However, when I view the blog post while still logged on, it shows the post's UserTime which is my GMT+1, but with .AddHours(Profile.Timezone - CSContext.Current.SiteSettings.TimezoneOffset). (Incorrect, result is GMT+7)
When I next logoff, and thus become the anonymous user, the blog post shows the GMT+1 DateTime. (Correct, UserTime is displayed, for the anonymous user the CS code does not adjust the DateTime. Which, on itself is still weird, I would expect the anonymous profile to correct a UTC/GMT DateTime to GMT+1 per the web.config setting)
When I next comment on the blog post, as the anonymous user, the comment displays the GMT-5 DateTime. (Incorrect, the same DateTime is saved to both UserTime and PostDate, I'd expect it to display GMT+1 per the web.config setting)
When I logon again and view the same comment, it displays the GMT+1 DateTime. (Correct, here there are also 6 hours added to the DateTime retrieved from the database)
The blog post itself shows the post's UserTime (GMT+1) but with .AddHours(Profile.Timezone - CSContext.Current.SiteSettings.TimezoneOffset), so in my case the code adds 6 hours to an already GMT+1 DateTime (1 - (-5) = 6).
This results in a blog post that I used for testing at the time of this writing, January 4th, 2008 6:19PM (GMT+1), displaying January 5th, 2008 12:19AM. (Incorrect)
I think that in some cases you save the wrong DateTime to the database, and in some cases you perform time zone adjustments that should not be done.
At this moment, for blog posts, you are saving to the database a UserTime GMT+1, and a PostDate GMT-5.
Wouldn't this all be solved if you would save only a single UTC/GMT DateTime to the database and let only the user profile setting determine what should be displayed?
I hope this reply explains what the problem is and is not confusing. I am looking forward to you reply.
I believe I see what the issue is. Are you running your SQL Server and Windows Server as one? Or are they on seperate boxes?Thanks,Ryan Howard
I believe I see what the issue is. Are you running your SQL SQL and Windows Server as one? Or are they on seperate boxes?Thanks,Ryan Howard
Well it sounds like the problem is a mismatch on the time zones, meaning the server and sql box are in two different time zones. So when a post is made the sql box uses it's current time to stamp the post with. Then on the forums that's what you see.
Thanks,Ryan
Well it sounds like the problem is a mismatch on the time zones, meaning the server and sql box are in two different time zones. So when a post is made the sql box uses it's current time to stamp the post with. Then on the forums that's what you see. Thanks,Ryan
One problem I've found is that hosts often tend to leave their servers set up to use -8GMT time, regardless if they're in a Pacific Time Region, Europe etc, and often they apply those rules to some servers, and not others, which might cause problems if your database server is on a different one to your webserver.
Community Server Documentation please rate articles you read
Nintendo Wiikly | My Blog
Copyright© 2008 Telligent Systems Inc. All rights reserved CommunityServer.com • Telligent.com