DateTime value is different across different versions of .NET framework

家住魔仙堡 提交于 2019-12-24 04:57:12

问题


I have a service(Language: VB.NET, Framework:.NET 3.5) that returns a dataset from which I read a date. The value of the column in the database is: "1980-03-30 00:00:00.000".

In a client(Language: C#) that uses .NET 3.5, the value is coming thorough as : 3/30/1980 12:00:00 AM

However, when I change the same client to use .NET 4 or .NET 4.5, the date which comes through the service is: 3/29/1980 11:00:00 PM


回答1:


The difference in DateTime values is not because of .Net framework, its because of the locale settings.

Never pass DateTime values through your web service, pass DateTimeOffset and then convert to DateTime type in your client.



来源:https://stackoverflow.com/questions/20222651/datetime-value-is-different-across-different-versions-of-net-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!