I've spent quite a bit of time on stackoverflow and the internet trying to determine what has been done in my situation. I am building a centralized line of business website that could span multiple timezones. Based on some valuable information here I have a plan in place to handle this.
- Timezone will be a part of a user profile
- All Dates will be stored in UTC
- EF sets DateTimeKind to UTC on retrieval from database Is it possible to prevent EntityFramework 4 from overwriting customized properties?
- Create some html helpers for DatePickers and DateDisplays to convert UTC time to local time (based off user timezone)
- Use Model Binding to convert back to UTC on form posts. Timezone Strategy
Now to the issue I don't know how to solve. Kendo UI uses JSON to pass information back and forth and as far as I can tell the JSON.net serializer cannot serialize a date to a specific time zone. I can serialize the date as UTC or have JSON.net automatically convert it to local time using the DateTimeZoneHandling setting but that would be local time on the server. From looking at the JSON.net code, I'm not sure I could even write a converter to do what I wanted. So far now if I send the date as UTC through JSON.net and Kendo automatically converts the time to the browser's local timezone.
Assuming User Profile timezone = Browser Timezone seems a little scary for me and I wanted to see what stackoverflow suggests I do. Thank you in advance.
Technology
ASP.net MVC 5
Entity Framework 6
Telerik Kendo UI Controls
JSON.net