What is the simplest way to get the machine's time zone as a positive or negative UTC offset, preferably using some time of shell command?
+2
A:
For all Unix-ish operating systems, when using the GNU date command:
date +%z
Example, for Eastern European Time (my timezone):
[moocha@helium ~]$ date +%z +0200
Mihai Limbășan
2008-12-08 07:00:52
+1
A:
If what you want is the non-summer/daylight-savings offset, you'd have to do something like:
date -d 'Jan 1' +%z
(or Jul in the southern hemisphere). This works with date from GNU coreutils, anyway.
Shockingly enough, I don't see any way to get the tm_isdst flag from date.
ysth
2008-12-08 07:26:03