Events and different time zones
Hi.
I have a few time zone related questions about events.
Let's say you're posting events on your website which are sponsored by your company/organization. Your company is in Central Time Zone. Most events are located in the same time zone as the company itself. However, some events are, let's say, on East Coast.
For example, let's say one such event, Conference XYZ, starts at 2:00 pm Eastern time. When you create the event in Sitefinity backend, you would have to set it according to Central Time, yes? So, you'd set it for 1:00 pm Central Time because your CMS is set to that. Correct?
But this doesn't necessarily make sense to visitors. They go to our website, see the calendar of events, they know Conference XYZ is on East Coast, and they see that it says Start 1:00 pm. They would be RIGHT to assume that's local (Eastern) time because the event is there. They don't know the company is located in Central Zone, and nor should they care. They themselves might be in an entirely different time zone. All they want to know is when and where is the event.
So my question is, how to handle these kinds of situations? Surely this is not all that uncommon of a situation!
Related question.... With SF 6.0, users can download events into iCal, Outlook, etc. How is time zone handled there? In the above example, how would Conference XYZ event show up on a user's computer who is in Eastern time zone? 1pm or 2pm?
Thanks.
Hi Marko,
When you create an event and you are for example UTC/GMT +2 hours and it is 09:00 pm (the time of your server) in the database this time is saved in standard UTC, two hours earlier e.g. 07:00 pm. When a user from German for example want to see the time of the event, this event is taken from the database in UTC time and is converted to the server time. So the user will see that the event is created in 09:00 pm. If you want to change the time of your server go to Administration -> Settings -> TimeZone and the Browser or Specific timezone offset configuration is located under Administration -> Settings -> Advanced ->System ->UI Time Zones Config. It is the same when you create the items via code.
When you create the items via code. If you say for example DateTime.UtcNow it will take your UTC time, in the database will be save as UTC and then will be converted to the server time when someone try to see it. Please note that you should always persist time according to a unified standard that is not affected by daylight savings. GMT and UTC have been mentioned by different people, though UTC is used in Sitefinity.
Regarding your second question, the events will be taken from the database as well be converted to user's server time.
Regards,
Stefani Tacheva
Telerik
Thanks, Stefani, but that doesn't really address my question fully. I understand that I can change the Time Zone in Sitefinity settings, of course. I understand that I can convert the time from UTC to any time zone by doing a conversion in code. That's not the question.
In your example, the user from Germany would see an event as 9 pm, because that's the time of the server. I can change the Time Zone of the server, but why? The server is in UTC +2, like you said. Plus, if I change the Time Zone (either in server OR through code when getting the time) so it makes sense to German visitors, how will US visitors interpret that?
Do you see what I mean? If an event occurs at 9:00 pm UTC/GMT +2 time, then ALL VISITORS, no matter where they come from, should be able to see the correct time.
I realized in asking this question, that the REAL question here is how to tell the visitors what time zone the event is in. That way, displaying a time PLUS a time zone will tell the user exactly when this event occurs. They can do the math to figure out when this happens in their time. Let me know if you have some thoughts about this.
Regarding my second question. You said:
"the events will be taken from the database as well be converted to user's server time."
I don't understand. Converted to user's time (let's say in Germany, which is UTC/GMT + 1)? Or Server time (let's say server is in UTC/GMT + 2)?
Hi,
Let me elaborate a little bit on the Events dates functionality, so maybe we can better explain how this part of the system is designed.
When you enter an EventStart/EventEnd, the value is perssited in UTC in the database (meaning the value in the database will always be different from the one entered, unless you have configured your site to be in UTC timezone as well. Then when the control is displaying the events on the frontend it is checking the user's browser and adjusts the UTC value according to the time zone you are in.
So for example we are located in Bulgaria, which is GMT +2:00. If I enter an event here that will start at 14:00 it will be persisted in the database as 12:00. Then if a user in the UK views this event it will display its start item as 12:00 since they are in UTC time zone. If a user in Germany views the same event it will display as 13:00 and if someone in Bulgaria views it it will show 14:00. This is done to present the user with the accurate information on what time the event starts according to his current location.
Regards,
Stefani Tacheva
Telerik
"...Then when the control is displaying the events on the frontend it is
checking the user's browser and adjusts the UTC value according to the
time zone you are in."
Hmmm, does this functionality exist prior to SF 6.0? I'm trying this right now in 5.4, and it doesn't work under these circumstances:
- Our production web server (running SF) is in UTC -6:00. SF Time Zone settings are set to UTC -6:00.
- My desktop is in UTC - 5:00.
- My development VM is in UTC.
If I view full details of an event from my desktop, I see it as 1:00 pm. If I view it from my VM, it ALSO shows it as 1:00 pm, even though my desktop and my VM are in two completely different time zones.
I have the following in my FULL DETAILS widget template:
<
asp:Literal
runat
=
"server"
Text='<%# ((DateTime)Eval("EventStart")).ToLocalTime().ToString("f") %>' />
Hello,
Would it be possible for you to use:
<
sitefinity:TextField
runat
=
"server"
DisplayMode
=
"Read"
Value='<%# ((DateTime)Eval("EventStart")).ToLocalTime().ToString("dd-MM-yyyy") %>' />