Title: Offset from GMT standard time
Tags: unix;shell;gmt
Question: Does Unix store the offset of the machine from GMT internally?
like for eg:india standard time is GMT + 5:30.is this 5:30 stored some where?
i need this to use it in a script like below
if[[ off is "some value"]]
some statements
Comment: Yes... and if you ask a *specific* question you might even learn how to do something useful with it! :)

Here is the accepted answer: The following program prints '-04:00' for me in EDT and prints '04:30' when I set TZ to 'Asia/Kolkata':
#include <stdio.h&gt;
#include <time.h&gt;
main ()
int hours;
int minutes;
int negative_sign = 1;
tzset ();
// printf ("tzname: %s tzname[1]: %s\n", tzname [0], tzname [1]);
// printf ("DST: %d\n", daylight); /* 0 when no DST */
// printf ("timezone: %ld\n", timezone);
/* 'timezone' is the number of seconds west of GMT */
/* It is negative for tzs east of GMT */
if (timezone <= 0) {
timezone = -timezone;
negative_sign = 0;
if (daylight) {
timezone -= 3600; /* substract 1h when DST is active */
if (timezone <= 0) {
timezone = -timezone;
negative_sign = 0;
}
timezone /= 60; /* convert to minutes */
hours = timezone / 60;
minutes = timezone % 60;
printf ("%s%02d:%02d\n", (negative_sign ? "-" : ""), hours, minutes);
return 0;
Feel free to use/change whatever you want and then call it from your shell script.

Here is another answer: In the kernel or a driver, no.
Usually, it's stored in a file called /etc/localtime. That file is often a link to a file elsewhere that contains (in compressed form) all the "rules" for converting GMT to the local time, including when daylight saving time begins and ends, the offset from GMT, and so forth.
Comment for this answer: It is overridable by the `TZ` environment variable.

Here is another answer: The kernel keeps GMT time internally, and when asked for the local time calculates the offset using the timezone information. This way, if a timezone change is required, internally, the clock doesn't need change.

Here is another answer: Traditionally in UNIX, the kernel keeps the current time in a timezone-independent form, which is what it reports to applications.
Applications consult environment variables and/or user configuration (which can be different for different users or different sessions for the one user) to determine which timezone to report the time in.  For this purpose, there are tables kept on disk which hold the offsets of all timezones that the system knows about (these tables need to be continuously updated for political changes to daylight saving algorithms).

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 4, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2009:00:12/09/09', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<unix><shell><gmt>', 'Title': 'Offset from GMT standard time', 'ViewCount': 617, 'id': 1871434, 'user_AboutMe': '<p><a href="http://theunixshell.blogspot.com/" rel="nofollow">http://theunixshell.blogspot.com/</a></p>\n', 'user_AccountId': 45665.0, 'user_DisplayName': 'Vijay', 'user_Reputation': 63327.0, 'user_Views': 5075.0, 'user_id': 134713.0}}