Do not change the system timezone.
Run one date command using UTC through the TZ environment variable.
Which command is appropriate?
A temporary TZ assignment before a command applies the timezone only to that process.
Detailed explanation
TZ=UTC0 date '+%Z'Correct. The date process uses UTC0 without changing the system configuration.
Correct. The date process uses UTC0 without changing the system configuration.
LANG=UTC0 date '+%Z'Incorrect. LANG controls locale, not timezone.
Incorrect. LANG controls locale, not timezone.
date TZ=UTC0 '+%Z'Incorrect. TZ is passed as a date argument rather than an environment assignment.
Incorrect. TZ is passed as a date argument rather than an environment assignment.
timedatectl UTC0 date '+%Z'Incorrect. timedatectl changes system settings and is not used in this wrapper form.
Incorrect. timedatectl changes system settings and is not used in this wrapper form.
Try it yourself
An example you can run in a temporary verification environment.
TZ=UTC0 date '+%Z'Expected result
UTCKey points
- TZ is timezone variable
- Temporary assignment
- No system-wide change
Notes
- Environment: GNU date / POSIX TZ形式UTC0
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.