?
Solved

Regarding Timezone and date command

Posted on 2006-06-07
12
Medium Priority
?
693 Views
Last Modified: 2013-12-26
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?

0
Comment
Question by:pigeon5566
  • 4
  • 3
  • 2
9 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 16856911
Day light savings doesn't change your timezone, so after October, the date command will give you the daylight savings time in the EDT timezone.

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.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 16856914
BTW, you can change the timezone on HP/UX by using 'sam'.
0
 

Author Comment

by:pigeon5566
ID: 16859950
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?
 
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:pigeon5566
ID: 16859985
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;

0
 
LVL 7

Expert Comment

by:glassd
ID: 16868515
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


0
 

Author Comment

by:pigeon5566
ID: 16877994
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?
0
 
LVL 48

Accepted Solution

by:
Tintin earned 100 total points
ID: 16931794
2.  You can temporarily change the timezone by simply doing:

TZ=mytimezone ; export TZ

or to change permently, use 'sam'.

3.  Vendors are always providing patches based on changes to day light savings times, so I'd imagine HP should already have a patch available.
0
 
LVL 7

Expert Comment

by:glassd
ID: 16932500
I don't think you can change the timezone on the fly. It is read by init so can only be set on boot.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 16938092
You *can* change the timezone for your current environment/shell, but obviously, it won't affect other processes.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Screencast - Getting to Know the Pipeline

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question