0

I'm running Playwright code in a Docker container on my Raspberry Pi. After taking a screenshot with Playwright, I noticed that the browser's timezone seems to be GMT instead of my local timezone CEST.

When running date on my Raspi, it returns:

myUser@myRaspi:~ $ date
Sun 11 Jun 16:17:55 CEST 2023

I've mounted my Raspi's timezone information into the container via volumes like this:

volumes:
  - /etc/timezone:/etc/timezone:ro
  - /etc/localtime:/etc/localtime:ro

Now inside my Docker container, the timezone seems to be properly set:

root@b2c5d9540130:/app# date
Sun Jun 11 16:18:57 CEST 2023

However, when running the Playwright code, the screenshot still shows GMT time:
enter image description here

So how do I configure Playwright's Chromium so that it considers the Raspi's timezone?

Thx!

PS: link to my project on GitHub

mu88
  • 4,156
  • 1
  • 23
  • 47

1 Answers1

0

playwright image is using as a base ubuntu. Ubuntu is exposing ENV TZ so you can control which timezone to be available inside the container when it starts.

Use ENV TZ="America/New_York" inside Dockerfile or pass it as environment CLI flag when starting the container.

Infern0
  • 2,565
  • 1
  • 8
  • 21
  • Thank you, but as you can see in my [`Dockerfile`](https://github.com/mu88/ScreenshotCreator/blob/main/src/ScreenshotCreator.Api/Dockerfile), I'm using the ASP.NET Core image rather than Playwright – mu88 Jun 12 '23 at 08:05
  • I think TZ is standard env / arg to change zone in most dockerized OS. As i see MS dotnet is using debian/ubuntu as base so it should works. – Infern0 Jun 12 '23 at 11:37
  • I've added `TZ="Europe/Zurich"` to my `docker-compose.yml`, but the screenshot is still GMT. Furthermore I noticed that `echo $TZ` on my Raspi returns nothing, so it does not seem to be set - since I want to consume my Raspi's timezone, there must be another way than `TZ` – mu88 Jun 12 '23 at 15:27