Bug in Events Beta2?
I am experiencing some sort of bug in the Events module and was wondering if you were aware of this or not.
I create or edit an event in the Events UI. I enter an event start time and end time and click "Save changes." When I view the event again via the Events UI, the time is shown as the exact time that I entered before. However, when I view the event on my website, which is using the API to access the start and end time, the time is displayed as being five (5) hours ahead of the time I specified when creating or editing the event in the UI.
I am assuming this has to do with timezones. Is there anywhere I can set the timezone on events? I am in EST in the US so it looks like the event is displaying in GMT.
Thank you,
Ann
Hello Ann,
Thank you for contacting us.
All datetime objects are stored in database as GMT. In the UI we are converting all dates to local time, however since you are working directly with the objects stored in the database there is no conversion applied to them. That is why, when working with the API and you want to create a custom functionality to display the events or any other object that is of type DateTime, you have to convert them to local time. Sitefinity is using the following code to convert the datetime to local based on the user's time zone.
public
DateTime ToLocal(DateTime value)
var timeZoneInfo = UserManager.GetManager().GetUserTimeZone();
return
TimeZoneInfo.ConvertTime(value, timeZoneInfo);
Greetings,Thank you, Hristo, that makes sense!