The current time in Los Angeles is 18:05. But when I run
TZ=UTC-8 date --iso=ns, I get:
The date utility tells me that the time is 10:05, and even says that it's reporting it as UTC+8. Why?
The reason is that
(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:
Whenever you specify a timezone in the format of +/-00:00, you are specifying an offset, not the actual timezone. From the
This is why it appears to be the reverse of what you expect.
As an alternative method you can use the command
The same rules apply with the timezones; west of the prime meridian being "behind" while to the east being "ahead".
$ zdump PST PST Sat Dec 7 03:25:27 2013 PST
I made this script to show several of the timezones + offsets that we're interested in using
Then when you run it you can see the comparison of
Because POSIX requires it.
So, this will give time near
And this should give the time near
 Near because there may be some DST (Daylight Saving Time) in effect that shift the actual "local time".