Epoch quest

Epoch quest

am 30.01.2007 14:55:07 von George

Just a generic question about epoch.
The perl 0 time seems to be "Thu Jan 1 02:00:00 1970"
because thats what I get for
print scalar(localtime(0));

So why I have to add 1900 for getting the correct year
print (((localtime(time))[5]) + 1900);

It should be 1970 , and ((localtime(time))[5]) should
return a different (bigger number) ...

Re: Epoch quest

am 30.01.2007 21:39:04 von Joe Smith

George wrote:
> Just a generic question about epoch.
> The perl 0 time seems to be "Thu Jan 1 02:00:00 1970"

Actually, it is 1970/01/01 00:00:00 GMT (1969/12/31 16:00:00 PST).
And it's not just perl - that epoch definition is a long-time part of Unix.

> So why I have to add 1900 for getting the correct year
> print (((localtime(time))[5]) + 1900);

Because that is how it is defined in UNIX.
For 1970 to 1999, it is a number from 70 to 99.
For 2000 to 2038, it is a number from 100 to 138.

-Joe