开发者

How do I transfer my dates properly from browser to server

I have to situations where I tra开发者_StackOverflownsfer dates from browser to server.

1) First situation is through a jQuery/JSON call to an ASMX service (.NET 4.0).

2) The second situation is when page first serializes an object, which includes a date, to a hidden field and then the page is posted to server. The hidden field is parsed (using .NET's built in JavaScriptSerializer).

So, let's say the user enters the date "2011-08-31". In the first situation the resulting date on the server is 2011-08-30 22:00 (because I am currently in a +2 time zone). However, in the second situation the resulting date on the server is 2011-08-31 (correct).

Both situtations use the same JSON serializer on the browser.

But I cannot understand why these two are generating different dates on server :-( Does anyone know?


You need to use UTC dates, take a look at these resources:

get UTC Date in javascript

converting UTC with C#

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜