Reputation: 345
We have an web application in India that access web service in US. Of late I have noticed an issue date that is stored in the database. I am checking for a condition in the application and if it fails, I am using Convert.ToDateTime(strDatetime)
where strDatetime
has the value "January 1, 1900". When I pass the datetime to the web service, instead of receiving the value as "01-01-1900 00:00:00" it is receiving it as "31-12-1889 10:30:00". This problem started occurring only recently.
How do I solve this problem? All I want to do is save the Date time with time as "00:00:00". I pass the value as Datetime and in web service, I also receive it as Datetime. So why is it that it's converting?
Upvotes: 2
Views: 959
Reputation: 345
I was able to solve the issue by sending the datetime as string to the web service and then use Convert.ToDatetime(string) method in the web method. This solves my problem.
Regards.
Jollyguy
Upvotes: 0
Reputation: 89
Convert UTC time to local when you are using the date from other timezone.
http://msdn.microsoft.com/en-us/library/system.timezoneinfo.converttimefromutc(v=vs.110).aspx
Upvotes: 2
Reputation: 1301
Be sure to handle timezones correctly. Either creating your times as UTC or sending the correct information in timezone.
Upvotes: 2