Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding timezone in HttpRequest from server side

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?

like image 435
Elad Benda Avatar asked Aug 26 '26 05:08

Elad Benda


1 Answers

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.

like image 142
competent_tech Avatar answered Aug 27 '26 19:08

competent_tech