How can I find which time-zone is currently in effect on my system and get offset to it?

I need this information in order to offset some time calculations and I cannot make it constant because of daylight saving time (which effectively changes offset).

E.g. Currently my time-zone offset is +02:00 and it will be +01:00 during winter. I need to get which one it is and offset in hours (e.g. in this case answer should be 2).

I would need to do this in either tcsh or bash.

From command line it looks like time-zone isn't set (date "+%z" returns 0). However, from web interface time-zone is set to Europe/Zagreb. I would like to get offset to that time-zone.

Version of FreeNAS is 0.7 RC1.

link|improve this question

75% accept rate
feedback

2 Answers

up vote 2 down vote accepted
$ date "+%Z"

Will give you the current timezone

$ date "+%z"

Will give the offset from DST

link|improve this answer
I tried this already but both of them give me 0. – Josip Medved Aug 21 '09 at 5:33
It seems that FreeNAS just removed bunch of stuff in order to save on size. However, what made me look on wrong side is that web interface does allow time-zone to be set to Europe/Zagreb. That setting is never "flushed" to file system. – Josip Medved Aug 21 '09 at 5:37
Dang :( No idea, then. How about "echo $TZ" in a terminal? – Bill Weiss Aug 21 '09 at 14:28
I suppose "no idea" isn't correct, since I followed that with an idea. – Bill Weiss Aug 21 '09 at 14:29
feedback

FreeNAS runs on FreeBSD, so using http://www.cyberciti.biz/faq/howto-set-date-and-time-timezone-in-freebsd/ as a guide:

FreeBSD Setup Timezone

To setup corrct timezone you need to copy your timezone file from /usr/share/zoneinfo directory to /etc/localtime file. Just goto directory:

# cd /usr/share/zoneinfo

Use ls -l command to find out your zonefile.

# ls -l

For example I am in Asia/Culcatta (IST time zone) so I need to copy file as follows:

# cp /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
link|improve this answer
I need time offset. I am not sure how this helps. :( P.S. FreeNAS has read-only file system (embedded version at least). – Josip Medved Aug 20 '09 at 23:15
Time offset IS your timezone...? AFAIK in FreeBSD your system clock should be set to UTC, and then the timezone file tells the OS how to adjust the time to your local time. Thus, to change your local time from +2 to +1 you change the timezone file. – Mark Henderson Aug 21 '09 at 0:04
@Farseeker: While this would work on FreeBSD, FreeNAS stripped bunch of things and made it's file system persistent. Whichever change I make, it will not be persisted across reboots. – Josip Medved Aug 21 '09 at 5:40
@Farseeker: Additionally, these functions do not return me offset as number. And that is what I need. A number. – Josip Medved Aug 21 '09 at 5:41
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.