Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect User based on Timezone

I was wondering if there was a way using JavaScript to redirect a user based on their timezone?

Like if timezone is between gmt-12 and gmt-8 redirect to page1.htm for example.

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

Thanks.

like image 706
user990175 Avatar asked May 22 '26 22:05

user990175


1 Answers

You could use window.location:

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

if (offset <= 720 && offset >= 960) {
  window.location.href = 'page1.htm';
}
like image 145
rjz Avatar answered May 25 '26 11:05

rjz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!