Display Asia/Tokyo local time only for date.
Do not change the system-wide time-zone setting.
Which command is appropriate?
TZ=ZONE COMMAND passes a time-zone override only to that command's environment.
Detailed explanation
TZ=Asia/Tokyo dateCorrect. It runs date with Asia/Tokyo only for that process.
Correct. It runs date with Asia/Tokyo only for that process.
date TZ=Asia/TokyoIncorrect. date treats TZ=Asia/Tokyo as a date argument.
Incorrect. date treats TZ=Asia/Tokyo as a date argument.
LC_TIME=Asia/Tokyo dateIncorrect. LC_TIME controls locale formatting, not the time-zone selection.
Incorrect. LC_TIME controls locale formatting, not the time-zone selection.
LANG=Asia/Tokyo dateIncorrect. LANG selects locale defaults, not a time zone.
Incorrect. LANG selects locale defaults, not a time zone.
Try it yourself
An example you can run in a temporary verification environment.
TZ=UTC date '+%Z'; TZ=Asia/Tokyo date '+%Z'Expected result
UTCとJSTなど異なるzone略称Key points
- TZ selects a time zone
- Command-scoped override
- Different from LC_TIME
Notes
- Environment: GNU date / 親環境を変更しない
- 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.