Javascript's getTimezoneOffset returns wrong offset?
My computer's timezone is GMT-7:00 Mountain time US & Canada. I tried a javascr开发者_Go百科ipt example on w3cschool:
<html>
<body>
<script type="text/javascript">
var d=new Date()
var gmtHours = -d.getTimezoneOffset()/60;
document.write("The local time zone is: GMT " + gmtHours);
</script>
</body>
</html>
The result is: The local time zone is: GMT -6
Why does this function return an offset with 1 hour difference from the actual timezone on my machine?
You're currently in Mountain Daylight Time.
Let's think about another similar scenario. If your friend open on Android smartphone, is there any variable?
Can it return 0 if a user disables Javascript on Android or when he installed VPN app or other privacy Android app?
What does it mean 0 from new Date().getTimezoneOffset()? Is the user telling he is living in Australia a real liar? Or it can be from other programmatic blocking?
精彩评论