pigeon5566
asked on
Regarding Timezone and date command
1. I am working on HP-UNIX 10.2. When i do a date command on my dev machine i am getting the below details
date
Wed Jun 7 10:56:16 EDT 2006
When i read about Daylight savings,it start at april and ends at october. So after October when i give the date command will it show EDT or change it to someother Timezone?
2. How do the timezone is set with/without daylight saving in UNIX system. After system is rebooted will it change. If i need to change it to GMT how do i do it?
date
Wed Jun 7 10:56:16 EDT 2006
When i read about Daylight savings,it start at april and ends at october. So after October when i give the date command will it show EDT or change it to someother Timezone?
2. How do the timezone is set with/without daylight saving in UNIX system. After system is rebooted will it change. If i need to change it to GMT how do i do it?
BTW, you can change the timezone on HP/UX by using 'sam'.
ASKER
1. So once set in the HPUX system timezone as EDT ,then date command will show always as EDT and system will automatically adjust 1 hr behind after april and add 1 hr after october. If i set the timezone as EST, then date command will show always as EST and system will not do subtract 1 hr after april and add 1hr after october. Pls correct me if i am wrong.
2. Is there any C function or UNIX Command to change the timezone of the UNIX system.
3. The daylight savings time is changing from 2007 year according US govt. Basically what HP people will do. Install a Patch? If yes why do they need to do this one?
2. Is there any C function or UNIX Command to change the timezone of the UNIX system.
3. The daylight savings time is changing from 2007 year according US govt. Basically what HP people will do. Install a Patch? If yes why do they need to do this one?
ASKER
Apologies i forgot to add this one to my previous question list
4. I am not aware what this program is trying to do. Can you explain me
long the_time = 631152000; /* seconds on Jan 1, 1990 00:00:00 */
short num_days = 0, year;
extern long timezone;
extern int daylight;
daylight = 0; /* we make no correction for daylight
savings time */
strcpy(tzbuf, getenv("TZ"));
if (strlen(tzbuf) > 3) {
timezone = (tzbuf[3] - '0')*60*60;
}
else {
timezone = 6*60*60; /* default central time */
}
num_days = day_of_year(s_month, s_day, s_year)- 1;
for (year = 1990; year < s_year; year++)
num_days += day_of_year(12, 31, year);
the_time += num_days*60*60*24 + s_hours*60*60 + s_minutes*60 + s_seconds + timezone - 60*60*daylight;
4. I am not aware what this program is trying to do. Can you explain me
long the_time = 631152000; /* seconds on Jan 1, 1990 00:00:00 */
short num_days = 0, year;
extern long timezone;
extern int daylight;
daylight = 0; /* we make no correction for daylight
savings time */
strcpy(tzbuf, getenv("TZ"));
if (strlen(tzbuf) > 3) {
timezone = (tzbuf[3] - '0')*60*60;
}
else {
timezone = 6*60*60; /* default central time */
}
num_days = day_of_year(s_month, s_day, s_year)- 1;
for (year = 1990; year < s_year; year++)
num_days += day_of_year(12, 31, year);
the_time += num_days*60*60*24 + s_hours*60*60 + s_minutes*60 + s_seconds + timezone - 60*60*daylight;
To expand on what Tintin said:
Unix systems world wide should be running Universal time (UTC) whic is generally GMT. The timezone is applied to the UTC so the date command will calculate the local time from UTC and the timezone. You can use "date -u" to see the universal time.
There is a set of rules for each timezone which calculate when to start and stop daylight saving for that timezone. So if I log onto one of our servers in Rio I get:
# echo $TZ
Brazil/East
# date
Fri Jun 9 06:16:41 EST 2006
# date -u
Fri Jun 9 09:16:52 GMT 2006
And if I do the same in the UK I get:
# echo $TZ
GB
# date
Fri Jun 9 10:17:11 BST 2006
# date -u
Fri Jun 9 09:17:17 GMT 2006
Unix systems world wide should be running Universal time (UTC) whic is generally GMT. The timezone is applied to the UTC so the date command will calculate the local time from UTC and the timezone. You can use "date -u" to see the universal time.
There is a set of rules for each timezone which calculate when to start and stop daylight saving for that timezone. So if I log onto one of our servers in Rio I get:
# echo $TZ
Brazil/East
# date
Fri Jun 9 06:16:41 EST 2006
# date -u
Fri Jun 9 09:16:52 GMT 2006
And if I do the same in the UK I get:
# echo $TZ
GB
# date
Fri Jun 9 10:17:11 BST 2006
# date -u
Fri Jun 9 09:17:17 GMT 2006
ASKER
Glassd,
Thanks a lot for the info. I have queries regarding this also
2. Is there any C function or UNIX Command to change the timezone of the UNIX system.
3. The daylight savings time is changing from 2007 year according US govt. Basically what HP people will do. Install a Patch? If yes why do they need to do this one?
Thanks a lot for the info. I have queries regarding this also
2. Is there any C function or UNIX Command to change the timezone of the UNIX system.
3. The daylight savings time is changing from 2007 year according US govt. Basically what HP people will do. Install a Patch? If yes why do they need to do this one?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't think you can change the timezone on the fly. It is read by init so can only be set on boot.
You *can* change the timezone for your current environment/shell, but obviously, it won't affect other processes.
Time on Unix systems is stored as the number of seconds from Jan 1 1970 (on most systems) UTC. Any date/time displays/calculations are all based on the internal time.