0

I am using a vpn. My web browser is chrome.

When registering to a particular site, I gave a different location. The site gives me a notification every 10PM. The problem is it is giving notification in my local time not in the time-zone from which I have registered to the site.

The permission that are allowed to the site are

Motion sensors
JavaScript
Images
Background sync
Payment Handlers

No, Permission for Location is not allowed.

How does the site know my local time-zone though I am using a vpn.

Can a web browser take time from the machine and send it to the server via HTTP header or something?

What is going on here?

P.S. Just to be clear, it is not a browser notification which is allowed by Notifications in chrome browser. It is like stackoverflow notification (top right of the browser windows). One more thing, I access that site from a linux desktop and not a mobile device. Not sure, what that Motion sensors permission is doing there in my desktop.

Ahmad Ismail
  • 11,636
  • 6
  • 52
  • 87

1 Answers1

1

I may be missing something, but if you press F12 in your browser, and type this:console.log(`Time offset is ${-new Date().getTimezoneOffset()/60} hours`);, you can see your time offset, and if you type console.log(new Date());, you can see your current time.

That information can be sent when you're logging in.

document.getElementById('current-time').innerText = `Current date: ${new Date}\nTime Offset: ${-new Date().getTimezoneOffset()/60} hours`;
<div id="current-time">
</div>

EDIT:

Time zone offset code is adapted from this answer.

domaci_a_nas
  • 220
  • 2
  • 11
  • You are correct. `console.log(-new Date().getTimezoneOffset()/60);` is showing my timezone and `console.log(new Date());` is showing my time. Then why am I using a vpn? How can I change the time to show the time I want to show. – Ahmad Ismail Jan 11 '21 at 19:27
  • @blueray - Browser time zone is taken from your operating system's time zone setting, not from network connectivity. – Matt Johnson-Pint Jan 11 '21 at 19:31
  • @MattJohnson-Pint so, Do I have to change the time of my machine with the time of the location I am using to browse or is there any easier solution? – Ahmad Ismail Jan 11 '21 at 19:32
  • If you want the time zone to change, you have to change the time zone of your machine - at least on Windows. If you're on Mac OSX or Linux, you can set the value of the `TZ` environment variable to a different IANA time zone identifier, as you launch the browser. Ex: `TZ=America/Chicago chrome`. (Windows has no such capability because there is no concept of per-process time zone.) – Matt Johnson-Pint Jan 11 '21 at 19:55
  • 1
    There's also [Time shift extension for Firefox](https://addons.mozilla.org/en-US/firefox/addon/change-timezone-time-shift/). While the Date object is unaffected, the [Browser tools](https://webbrowsertools.com/timezone/) indeed reports changed time, so it may work on your website. Btw, do you have time zone in your profile settings? – domaci_a_nas Jan 11 '21 at 20:04
  • @domaci_a_nas no. They do not ask anything, just take it. – Ahmad Ismail Jan 11 '21 at 20:13
  • @domaci_a_nas - Unfortunately, that extension claims to be open source but doesn't provide a link to the source code. I've personally made several attempts at such an extension, but in the end it's not possible to do it *correctly* because the browsers themselves don't offer such a capability. Likely the author of that extension is making common errors, such as adding/subtracting time and thinking such an approach will adjust correctly for time zone (which it does not). Without seeing the source, it's hard to say. The feedback on the extension's page does have many reporting errors. – Matt Johnson-Pint Jan 11 '21 at 21:07