How to set, change or block timezone(systemtime) with Puppeteer?

后端 未结 2 921
别那么骄傲
别那么骄傲 2021-01-29 02:25
  • OS: Windows 10 Pro x64-based PC
  • node -v: v8.12.0
  • npm list puppeteer: `-- puppeteer@1.9.0

I tried this:

puppeteer.launch({
         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-29 02:50

    According to the Puppeteer documentation, you can use page.emulateTimezone():

    page.emulateTimezone()

    timezoneId Changes the timezone of the page. See ICU’s metaZones.txt for a list of supported timezone IDs. Passing null disables timezone emulation.

    returns:

    For example:

    await page.emulateTimezone('America/Chicago');
    

提交回复
热议问题