Time Zone Based User Redirection

I was wondering if there is a way to use JavaScript to redirect the user based on their time zone?

For example, if the time zone between gmt-12 and gmt-8 is redirected to page1.htm, for example.

I was looking at getTimezoneOffset (), but I don't know how to redirect it based on the result.

Thank.

+3
source share
1 answer

You can use window.location:

var date = new Date(),
    offset = date.getTimezoneOffset();

if (offset <= 720 && offset >= 960) {
  window.location.href = 'page1.htm';
}
+2
source

All Articles