1834187 Members
2526 Online
110064 Solutions
New Discussion

HPUX Unix epoch time

 
SOLVED
Go to solution
Shivkumar
Super Advisor

HPUX Unix epoch time

Dear Sirs,

Why do we use Unix epoch time ? What are programs or processes on HPUX which uses this time ?

I had read about it long years ago but never understood the significance of this epoch time ?

I thought it is better to ask the opinion of Unix gurus of this forum.

Thanks,
Shiv
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: HPUX Unix epoch time

Hi Shiv:

The "epoch" as far as UNIX is defines it is January 1, 1970 at 00:00:00 UTC. Time keeping in Unix counts in one-second intervals from the point.

32-bit systems can count only until January 19, 2938. Using negative times (before January 1, 1970) and positive values thereafter, we can reckon periods from Dec 13 20:45:52 1901 to Jan 19 03:14:07 2038.

The counting of seconds is done in UTC (Universal Time Zone Coordinates). What you and I perceive of as "time" is called "local" time and it the TZ (timesone) offset +- UTC or commonly Greenwich Mean Time (GMT).

Thus one-second after midnight on January 1, 1970 is really Wed Dec 31 19:00:01 1969 for me, in the US Eastern time zone since I'm 5-hours behind UTC (GMT). Regardless, all file and process timestamps record the number of seconds. You and I adjust for our local time.

Perl provides simple conversion methods for moving back and forth between epoch seconds and dates and time.

As I write, the current time is 1137973446 seconds since the epoch.

Given a number of seconds I can do:

# perl -le 'print scalar localtime(1137973446)'

...to get:

Sun Jan 22 18:44:06 2006

...which is my current (local timezone) time.

I can also use 'adb':

# echo 0d1137973446=Y | adb

Note the notation "0d" simply denotes decimal base.

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: HPUX Unix epoch time

Essentially every UNIX program uses epoch seconds as the standard clock. It's simply the number of seconds since Jan 1, 1970 00:00:00 UTC not counting leap seconds. The reason is very simple. It allows everyone to be on a level playing field. It's very common for a UNIX box to have users connected from around the planet --- and possibly beyond. Each of might have different TZ settings which convert epoch seconds to local time. By using one standard, it is possible, for example, to compare file timestamps independent of the user's TZ setting or even independent of the host computer because all UNIX boxes tick off the same epoch seconds --- or at least they should.
If it ain't broke, I can fix that.
Arunvijai_4
Honored Contributor

Re: HPUX Unix epoch time

Hi Shiv,

Unix epoch time is known as "Unix time or POSIX time". There are two layers of encoding that make up Unix time, and they can be usefully separated. The first layer encodes a point in time as a scalar real number, and the second encodes that number as a sequence of bits or in some other manner.

More information at, http://en.wikipedia.org/wiki/Unix_epoch

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"