CodeNewa
CodeNewa

Reputation: 127

DateTime value is different across different versions of .NET framework

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

Upvotes: 2

Views: 1198

Answers (1)

Habib
Habib

Reputation: 223287

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.

Upvotes: 3

Related Questions