I have just created list and in that list I create a datetime field, and I developed a C# program to get the list data, but when my program get datetime field value, have a wrong, in my sharepoint list, the datetime value is 2017/4/14 00:00, but in my program, the value is 2017/4/13 5:00 PM. I've searched on google so many times but have no result. Do anyone know about this problem? Please explain for me. Thanks!
-
Do you use Convert.ToDateTime(item[dateField]) or what?– Semushin DmitriiCommented Apr 14, 2017 at 4:56
-
yes, I did, but have no result.– GIANGPZOCommented Apr 14, 2017 at 6:20
-
Most likely a timezone difference between Server and Client you have to deal with programmatically– Danny '365CSI' EngelmanCommented Apr 14, 2017 at 7:31
-
@Danny'365CSI'Engelman the timezone is the same in both Server and Client.– GIANGPZOCommented Apr 14, 2017 at 8:32
-
TimeStamp difference? SharePoint starts counting at 31/12/1899 your C# code at 1/1/1900?– Danny '365CSI' EngelmanCommented Apr 14, 2017 at 11:17
|
Show 1 more comment
1 Answer
I spent a few days to find out the problem. Finally, I understanded the mechanism of saving datetime in SQL Server of Sharepoint: Sharepoint used the UTC timezone to store datetime value in Sql server (whatever your timezone is). Althought my timezone is UTC+7, but in SQL sever is UTC, so when C# client code access sql server to get data, it got the datetime value in UTC timezone.