Problem
Setting the TZ environment variable does not affect the system timezone on the macOS executor. This is because macOS uses a system-level timezone setting rather than reading the TZ environment variable for its clock, unlike Linux-based executors where TZ works as expected.
Solution
Use systemsetup to set the timezone as a step in your job configuration:
- run:
name: Set timezone
command: |
sudo systemsetup -settimezone "$TIMEZONE"
Replace $TIMEZONE with your desired timezone string (for example, America/New_York or Europe/London). You can list all supported timezones by running sudo systemsetup -listtimezones.
Note: if you only need to set the timezone for Docker-based jobs, the TZ environment variable works correctly there. See How do I set the timezone in Docker images?
Comments
Article is closed for comments.