PhantomJS set browser timezone setting

2019-07-12 19:12发布

问题:

I am running Karma with PhantomJS to run some unit tests.

In my unit tests there are some tests which do some date comparison which all pass when run locally.

Our build server is on a different timezone and the date tests are failing due to different timezones.

I looked at phantomjs options to and didn't see any option regarding locale or timezone. Is it possible to configure phantomJs to the same timezone on every computer even though they are different timezones ?

回答1:

If you're running it using a shell, you might use the TZ environment variable. E.g.

TZ=Europe/Berlin phantomjs script.js