This is a migrated thread and some comments may be shown as answers.

Date in grid is off by 1 day

10 Answers 1005 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Derek Kepler
Top achievements
Rank 1
Derek Kepler asked on 22 Jul 2013, 06:19 PM
Hello, 

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

Sort by
0
Vladimir Iliev
Telerik team
answered on 24 Jul 2013, 11:40 AM
Hi Derek,

 
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.

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Derek Kepler
Top achievements
Rank 1
answered on 25 Jul 2013, 12:23 AM
Hi Vladimir,

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.
0
Vladimir Iliev
Telerik team
answered on 25 Jul 2013, 07:32 AM
Hi Derek,

 
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.

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Derek Kepler
Top achievements
Rank 1
answered on 25 Jul 2013, 10:47 AM
Hi Vladimir, 

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
0
Vladimir Iliev
Telerik team
answered on 25 Jul 2013, 02:20 PM
Hi Derek,

 
As I mention in my previous reply we will need a runable example where the issue is reproduced to be able to help. 

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Derek Kepler
Top achievements
Rank 1
answered on 25 Jul 2013, 08:52 PM
Hi Vladimir, 

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.
0
Derek Kepler
Top achievements
Rank 1
answered on 25 Jul 2013, 08:54 PM
Hi Vladimir, 

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.
0
Vladimir Iliev
Telerik team
answered on 29 Jul 2013, 09:25 AM
Hi Derek,

 
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.

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
FranckSix
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 05 Aug 2020, 03:32 PM

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.

Replace Kendo serializer

0
Nikolay
Telerik team
answered on 07 Aug 2020, 10:40 AM

Hello Francis,

Thank you for sharing the solution you came up with. Although the link does not lead to a post I believe this might help others facing the same scenario.

Regards,
Nikolay
Progress Telerik

Tags
Grid
Asked by
Derek Kepler
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Derek Kepler
Top achievements
Rank 1
FranckSix
Top achievements
Rank 2
Iron
Iron
Veteran
Nikolay
Telerik team
Share this question
or