How to set a time zone in Puppeteer for page

Puppeteer allows blocking any outgoing requests while loading the page. Whether you want to block ads, tracking scripts, or different types of resources, it is relatively easy to do with Puppeteer.

1 min read

Written by

Dmytro Krasun

Updated on

By the way, in our screenshot API, you can take the screenshot of the element by specifying the time zone parameter.

Puppeteer allows changing the time zone on a per-page basis. In automation testing, you can test how the website behaves for different time zones. Or you can use it for scrapping to imitate the user from the expected time zone by the site.

It is reasonably simple to do by using page.emulateTimezone(timezoneId):

const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({});
try {
const page = await browser.newPage();
await page.emulateTimezone('Europe/London');
await page.goto('https://screenshotone.com/');
} catch (e) {
console.log(e)
} finally {
await browser.close();
}
})();

The list of available time zones you can find at Chromium source code, these are the most popular ones:

  • America/Santiago
  • Asia/Shanghai
  • Europe/Berlin
  • America/Guayaquil
  • Europe/Madrid
  • Pacific/Majuro
  • Asia/Kuala_Lumpur
  • Pacific/Auckland
  • Europe/Lisbon
  • Europe/Kiev
  • Asia/Tashkent
  • Europe/London

I hope I have helped solve the issue and I wish you a nice day!

Read more posts

Interviews, tips, guides, industry best practices, and news.

View all posts
Cloudflare Browser Rendering

Cloudflare Browser Rendering

Cloudflare recently launched a new Browser Rendering platform. I decided to dive into it and quickly check if I could use it in ScreenshotOne to provide a faster and better customer experience.

Read more

Automate website screenshots

Exhaustive documentation, ready SDKs, no-code tools, and other automation to help you render website screenshots and outsource all the boring work related to that to us.