Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup or change browser timezone #3325

Closed
angrykoala opened this issue Sep 30, 2018 · 11 comments
Closed

Setup or change browser timezone #3325

angrykoala opened this issue Sep 30, 2018 · 11 comments

Comments

@angrykoala
Copy link

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.8
  • Platform / OS version: linux
  • URLs (if applicable):
  • Node.js version: 8.12.0

I need to use Puppeteer with different timezones for testing purposes. Would it be possible to set the browser default timezone?

@DuBistKomisch
Copy link

You can override the timezone in chromium by setting the TZ env var. One way to do this is via env in the launch arguments, e.g.:

puppeteer.launch({
  env: {
    TZ: 'Australia/Melbourne',
    ...process.env
  }
});

@angrykoala
Copy link
Author

Thanks @DuBistKomisch I'll try that

@jcserracampos
Copy link

It's not working for me.

@doingweb
Copy link

In case anyone else coming across this also has the follow-up question:

What are valid values for the TZ environment variable?

It's the list of tz database timezone names.

@hym1884603
Copy link

In case anyone else coming across this also has the follow-up question:

What are valid values for the TZ environment variable?

It's the list of tz database timezone names.

It's not working for me too.

@khanh-dtp-vn
Copy link

It's not working for me too.

@DuBistKomisch
Copy link

still working for me... post some details if you expect any help

@crobinson42
Copy link

Does anyone know a way to change the timezone on the fly?

@DuBistKomisch
Copy link

DuBistKomisch commented Sep 17, 2019

@crobinson42 I don't think it's possible to change the env var without restarting the process, the only way to change it dynamically would be to change the actual system timezone and not use an env var at all.

@mathiasbynens
Copy link
Member

#4949

@crobinson42
Copy link

Solution

This was added in the above mentioned PR:

const page = await browser.newPage()

await page.emulateTimezone(timezone)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants