Why is the datetime behavior in JSON different from different systems (win xp, server 2003)?

My web application is divided into WebGui and WebService. WebService is responsible for processing business logic and databases. From Javascript in the browser, I request data depending on the date and time, which is the input from the browser. This gous request addresses .asmx Url in WebGui and a web service is called inside this function.

In my development system (windows xp) I get the data I need, but when I install it in the test system, I have to add the difference in the local time zone to get the correct data.

For example, I want the data for the date and time of '21 .07.2008 2008 14:27:30 'I have to send '21 .07.2008 to 16:27:30'.

Why is the behavior of the two systems different and what should I do to get around both systems equally?

  • Web GUI is in asp.net 2.0 C #
  • The web service is in asp.net 1.1 c #

Update

It is not a problem to interpret the date in different formats, since the date and time are sent in the JSON protocol as "/ Date (1221738803000) /". This is the problem of interpreting / forgetting the time zone.

+3
source share
4 answers

I suspect this is due to the DateTime.Kind property introduced in .NET 2.0. By default, this is a DateTimeKind.Unspecified value, which in most cases is handled the same as DateTimeKind.Local, so when the date is serialized, it will be converted to UTC. You can try setting the Date parameter to DateTimeKind.Utc using DateTime.SpecifyKind (...) before passing it to the web service call.

+3

-. : 01.05.2008 en-GB (.) , en-US 5 .

, , UTC (yyyy-mm-dd), .

0

, / , , , DateTime.Parse, DateTime .

0

Source: https://habr.com/ru/post/1697121/


All Articles