This project is read-only.


How to solve timezone issue?


I have MVC5 application where users are creating events with start and end date and that events accessible across many timezones.
So I can use MVC toolkit to get time as per as client timeZone?
I am very glad if you share me such example.

Please help me.
Closed Feb 15, 2014 at 2:34 PM by frankabbruzzese
Not An Issue


frankabbruzzese wrote Jan 31, 2014 at 10:41 AM

If you render the date on the server side with any of the Mvc Controls Toolkit controls, clearly the time server timezone is used.

In order to take into account the client side time zone you have just two options:
  1. You send someway the browser timezone to the server, into a cookie, or into an hidden field, so the server may use it whenever it renders a date. If you know the TimeZone offset on the server side you may convert any DateTime to that timezone, before rendering it.
  2. You don't render the datetime on the server side but on the client side by using client side techniques. Mvc Controls Toolkit has Client Blocks that are based on knockout.js. If you use client blocks all templates are translated into client side templates and rendered on the client side. In this case all Mvc Controls Toolkit controls automatically use the client side TimeZone
All dates in the examples in the Mvc4 IQueryable file in the download area are expressed in the client local TimeZone.

However, taking into accont TimeZone is a subtle stuff, because almost nobody knows some conventions on ,Net Datetime structures (they may be expressed either in local or in Utc time). I advice to read this blog post to understand well all problems involved in handling TimeZones: Mvc and the nightmare of Dates and Time Zones.

All Mvc Controls Toolkit API for handling Timezones are here.

wrote Feb 15, 2014 at 2:34 PM