有没有办法在Chrome devtools中更改您的时区?
我已经用JavaScript创建了一个工具,该工具可以确定当前UTC时间并检查是否已经过另一个预定日期.
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.
在Chrome开发者工具中有没有办法做到这一点?如果没有,还有其他建议吗?
Is there a way to do this in Chrome dev tools? If not, do any other suggestions come to mind?
要在Chrome Dev工具中执行此操作,可以使用Geolocation传感器仿真. 转到虚线3菜单,更多工具和传感器.
To do this in Chrome Dev tools you can use the Geolocation sensor emulation. Go to the 3 dotted menu, More Tools and Sensors.
有一个Geolocation下拉列表,其中包含一些常用位置,但是您也可以更改首选位置.为此,您可以在该下拉菜单中选择 Other ... ,然后输入自定义的时区ID
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
这是一个演示页面,可以对其进行测试: https://mathiasbynens.be/demo/timezone 以及显示该过程的视频: https://www.youtube.com/watch?v=pIpN_AuV4AI
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