I have a very strange issue. On one particular server every date value in a kendo grid is off by 1 day. So if a date in the database is 12/24/1990 it will render as 12/23/1990.
I have put up 2 test pages on 2 different servers to demonstrate this behavior. To deploy I published to a location on my machine and copied up to each location to ensure everything is identical.
TEST 1 - Problem server
MVC WEB GRID: shows the correct date values
http://beta.fpsrx.net/Test/Index
KENDO GRID: shows INCORRECT date values
http://beta.fpsrx.net/Test/KendoGrid
TEST 2 - A different server/different host - works as expected
MVC Web GRID
http://www.dilatingdesigns.com/Test/Index
KENDO GRID
http://www.dilatingdesigns.com/Test/KendoGrid
Any help is appreciated - I can of course either recalculate the date or create a new property on my model to compensate for this, but I really don't want to start down that road.
Thanks,
Derek
10 Answers, 1 is accepted
Basically current behavior is expected when the client and the server are using different time zones. There are several ways to handle correctly sending the dates between the client and the server side and which one you would choose depends entirely on you and the exact setup that you have. For example you can check this demo in our CodeLibrary which demonstrates how to use UTC time on both the client and the server side.
Vladimir Iliev
Telerik
I tried the project you sent and now the behavior seems to be happening on my local machine. Please see the 3 attached files. "Grid.jpg" shows the DOB column value of 11/19/1981 while both the "Code.jpg" and "Database.jpg" images show the value should be 11/20/1981. Also you can see the "Client.jpg" which shows the client side "convert" is being hit.
From the provided information it's not clear for us what is the exact reason for this behavior - could you please send us a runable project where the issue is reproduced as well as your local machine time zone? This would help us pinpoint the exact reason for this behavior.
Vladimir Iliev
Telerik
I got the sample working correctly. I still have one question though. I have another page without a grid where I do an update using a regular form post and when I submit on that form, the grid goes back to being off by 1 day again. What do I do in that case?
Thanks,
Derek
As I mention in my previous reply we will need a runable example where the issue is reproduced to be able to help.
Vladimir Iliev
Telerik
See the attached project.
Steps to reproduce:
1. When you run the application you should be taken to the Index page with a grid of 20 users.
2. Edit a user and change the DOB and Save.
3. On that user's row, click the 3rd button which should take you to a separate form.
4. Now, change the first name to anything - can just add a letter. Do NOT change the DOB.
5. Click Update.
6. Now if you go back to the Index page you should see the DOB has decreased by 1 day.
See the attached project.
Steps to reproduce:
1. When you run the application you should be taken to the Index page with a grid of 20 users.
2. Edit a user and change the DOB and Save.
3. On that user's grid row, click the 3rd button which should take you to a separate form.
4. Now, change the first name to anything - can just add a letter. Do not change the DOB. Save.
5. Go back to the index page. The "DOB" should be decreased by 1 day.
BTW - sorry if you got a million update emails on this. The forum kept telling me I put in invalid content.
Due to the missing DataBase in the project we are unable to the run the project, however I checked it and it seems that it's not setup correctly. I would suggest to check the demo in our CodeLibrary that I linked in my previous replies and setup your project correctly to have the same culture on both the client and the server side as well as to use UTC dates on both sides.
Vladimir Iliev
Telerik
If that can help. I found this post which allows to modify the serializer of Kendo (JavascriptSerialiser) for that of NewtonSoft. In my case it solved my date problem. My date in the comic has no hours and the Kendo grid displays my date correctly.