TZ
Sets the timezone for the process, affecting how times are displayed and how time-related functions operate. Uses the IANA Time Zone Database identifiers. When not set, the system timezone from /etc/localtime is used.
Last updated:
TZ sets the timezone for a single process using IANA Time Zone Database names like `America/New_York` or `Europe/London` — never raw offsets like GMT+2, because those ignore daylight saving. It is the cleanest way to make one service run in a specific zone without changing the whole machine: set TZ and the C library's localtime(), plus most language runtimes, immediately honor it. The standard advice still holds — store and compute in UTC, convert at display time — but TZ is what you reach for when a cron job, log timestamp, or report must render in a particular local zone.
- Provider
- General / OS
- Category
- locale
- Set by
- Set via environment variable, system settings, or /etc/timezone
- Example
- America/New_York
How to set TZ
run one command in a zone
TZ=Asia/Tokyo dateDocker (Alpine needs tzdata)
RUN apk add --no-cache tzdata
ENV TZ=Europe/Oslodocker-compose
services:
app:
environment:
TZ: America/New_YorkReferences
Frequently Asked Questions
I set TZ but the time is still UTC in my container. Why?
The timezone database is missing. Alpine and other slim images do not include tzdata, so the IANA zone you named cannot be resolved and the process stays on UTC. Install it (`apk add tzdata` / `apt-get install tzdata`) and make sure TZ uses a Region/City name, not an abbreviation like EST.
Stay up to date
Get notified about new guides, tools, and cheatsheets.