Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine user agent timezone offset without using javascript?

Is there a way to determine the timezone for a user agent without javasript?

normally, i would execute this snippet of javascript:

<script type="text/javascript" language="JavaScript">
 var offset = new Date();
 document.write('<input type="hidden" id="clientTzOffset" 
 name="clientTzOffset" value="' + offset.getTimezoneOffset() + '"/>');
</script>

However, for a lot of mobiles and clients, JS is either not existant or turned off. Is there something clever I can do or am I reduced to "tell me where you are and what timzeone you are in?"

like image 567
MikeJ Avatar asked Dec 23 '22 11:12

MikeJ


1 Answers

Use both. Have javascript set the default value of a list or text field. The percentage of people without javascript is so small the burden is tiny.

I was going to say "Use the request Date: header" but that's a response header only it seems.

like image 63
SpliFF Avatar answered Jan 30 '23 22:01

SpliFF