root@ubuntu:~# TZ=UTC-8 date +”%Y-%m-%d %H:%M:%S”
root@ubuntu:~# TZ=UTC-8 date +’%Z %z’
The reason is that
TZ=UTC-8 is interpreted as a POSIX time zone. In the POSIX timezone format, the 3 letters are the timezone abbreviation (which is arbitrary) and the number is the number of hours the timezone is behind UTC. So
UTC-8 means a timezone abbreviated “UTC” that is −8 hours behind the real UTC, or UTC + 8 hours.
(It works that way because Unix was developed in the US, which is behind UTC. This format allows the US timezones to be represented as EST5, CST6, etc.)
You can see that’s what’s happening by these examples:
$ TZ=UTC-8 date +'%Z %z' UTC +0800 $ TZ=UTC8 date +'%Z %z' UTC -0800 $ TZ=FOO-8 date +'%Z %z' FOO +0800
-0800 timezone format takes the opposite approach, with
- indicating the zone is behind UTC, and
+ indicating the zone is ahead of UTC.