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

♀尐吖头ヾ 提交于 2020-05-26 10:18:01

问题


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?


回答1:


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




回答2:


There's no way yet to do this from the DevTools, but I've filed a feature request to implement a way to override the timezone.

In the meantime, you can launch the browser with the TZ environment variable set to the desired timezone name on Linux/MacOS.




回答3:


This worked for me in windows 10. change the system timezone and refresh the page.



来源:https://stackoverflow.com/questions/50849770/is-there-a-way-to-change-your-timezone-in-chrome-devtools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!