سؤال

I have tried var dateHeaders = HttpContext.Current.Request.Headers["Date"] but it contains null, apparently there is no such key.

Can anyone tell me where else can I find the time-zone of the current client?

Reference: http://en.wikipedia.org/wiki/List_of_HTTP_header_fields

enter image description here

I want to parse dateTime to the following format:

Sun Nov 14 43745 00:00:00 GMT+0200 (Jerusalem Standard Time)

btw, what's the '43745' part?

هل كانت مفيدة؟

المحلول

The date header is not one that is sent in standard http requests. I just ran a quick check with fiddler using both IE and Firefox and didn't see the date header sent on any requests.

The best that you can do on the server is get the user's culture, but this will only help with the date format, not the timezone.

However, you can get the information from javascript using getTimezoneOffset. For example:

var timeNow = new Date();
var timezone = timeNow.getTimezoneOffset() / 60 * (-1);

There is an excellent description here.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top