This question is locked. New answers and comments are not allowed.
Hi,
I am using telerik extensions for Asp.Net MVC from last 1 year.
Earlier I noticed that there is some major difference between the date at server & in Sql Server & date that is rendered in telerik column.
Attached is the screen shot showing the date difference.
Can you suggest any centralized solution to overcome this problem, because till now have grids at lot more places & this issues is burning my heads.
After some googling I found that browser usually adds some time offset of browser time zone before rendering a date in javascript, so my simple solution was to subtract that browser time zone offset from the date I am getting.
So I added a javascript function to handle this but still the solution works in one time zones but for other it shows a lot more difference.
My server is located in Central time zone whereas users are all accross other timezones in US.
Can any one suggest me any solution for this?
here is my javascript function
and here is how it is used in grid, all my grids are ajax bound here
Thanks.
I am using telerik extensions for Asp.Net MVC from last 1 year.
Earlier I noticed that there is some major difference between the date at server & in Sql Server & date that is rendered in telerik column.
Attached is the screen shot showing the date difference.
Can you suggest any centralized solution to overcome this problem, because till now have grids at lot more places & this issues is burning my heads.
After some googling I found that browser usually adds some time offset of browser time zone before rendering a date in javascript, so my simple solution was to subtract that browser time zone offset from the date I am getting.
So I added a javascript function to handle this but still the solution works in one time zones but for other it shows a lot more difference.
My server is located in Central time zone whereas users are all accross other timezones in US.
Can any one suggest me any solution for this?
here is my javascript function
function parseToServerTimezone(date) { if (date != null) { var clientOffset = new Date().getTimezoneOffset(); var newDate = new Date(date); newDate.setMinutes(date.getMinutes() - clientOffset); return $.telerik.formatString("{0:g}", date); } return date; }and here is how it is used in grid, all my grids are ajax bound here
column.Bound(m => m.CapCycleStartDate).Title(Html.Resource("CapCycleStartDate")).ClientTemplate("<#= parseToServerTimezone(CapCycleStartDate) #>").Width(18).HtmlAttributes(new { align = "center" });Thanks.