Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change your timezone in Chrome devtools?

I've created a tool in JavaScript that determines the current UTC time and checks if another predetermined date has passed yet.

I'd like to change my browser to another timezone and see if the tests still pass but I'm having trouble finding a way to do this.

Is there a way to do this in Chrome dev tools? If not, do any other suggestions come to mind?

like image 718
iPzard Avatar asked Jun 14 '18 04:06

iPzard


People also ask

How do I change my DevTools location?

Change where DevTools is docked by using the Command Menu Or, press Shift + Ctrl + P on Windows/Linux or Command + Shift + P on macOS. Type dock, and then select a dock command: Dock to bottom. Dock to left.

What is Chrome timezone?

Chrome uses the timezone that comes from the operating system. So just go into your system preferences and change your timezone.


2 Answers

To do this in Chrome Dev tools you can use the Geolocation sensor emulation. Go to the 3 dotted menu, More Tools and Sensors.

There's a Geolocation dropdown with some common locations but you can change your preferred one as well. To do that you can choose Other... in that dropdown and enter a custom Timezone ID

Here's a demo page to test it: https://mathiasbynens.be/demo/timezone and a video that shows the procedure: https://www.youtube.com/watch?v=pIpN_AuV4AI

Timezone testing in Chrome developer tools

like image 71
fernandopasik Avatar answered Sep 21 '22 02:09

fernandopasik


2020 update: see the other answer, which shows the result of a feature request I filed with Chromium to implement a way to override the timezone.

Note that the technique only works to change the location (including timezone) in that tab. Other tabs will still use the system's timezone. DevTools isn't a reliable way to spoof your timezone.

To change the timezone for all tabs in the browser (Chrome or Firefox or whatever), on Linux/MacOS, you can launch the browser with the TZ environment variable set to the desired timezone name:

TZ=America/New_York chromium-browser 
like image 43
Dan Dascalescu Avatar answered Sep 20 '22 02:09

Dan Dascalescu