0

I have a SQL Server table the contents of which I'm displaying in an MVC page using Kendo UI Grid. One of the columns in the table is named RecordDate and is a SQL Server Date type (not a datetime variant).

When my page requests data, I'll retrieve some rows, convert to Json (as shown below) and return them to the client.

return Json(resultSet, JsonRequestBehavior.AllowGet);

The problem is all the dates are off by one day when displayed in the Kendo grid. I suspect something along the way is assuming the dates are stored as UTC dates (which they are not) and then attempting to convert to local time. However, I have no idea where this is happening, why and how to stop it.

Randy Minder
  • 47,200
  • 49
  • 204
  • 358
  • If you put a breakpoint at `return` line what is the value of the date? – CodeNotFound May 07 '17 at 19:36
  • @CodeNotFound This really isn't a valid test because when I run locally my time zone is the same time zone as the data in the table. This only happens when I run my app in the browser and hitting my code on Azure. – Randy Minder May 07 '17 at 19:49
  • Have you try different browser? I think the problem when UI Grid convert & shwo the data from json result. – andrefadila May 08 '17 at 03:40

1 Answers1

0

We have recently had a similar issue, there are a number of links which discuss this:

Stringify modifying dates

How to prevent modification of times

Server changing dates sent by client

Notably the best/most acceptable resolution (and one we decided to use) seems to be the use of the moment.js package to handle dates. However, as you will see throughout the links above, this is open to interpretation.

Community
  • 1
  • 1
Sandman
  • 2,247
  • 1
  • 13
  • 26