Epoch quest

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) ...
George [ Di, 30 Januar 2007 14:55 ] [ ID #1613370 ]

Re: Epoch quest

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
Joe Smith [ Di, 30 Januar 2007 21:39 ] [ ID #1613373 ]
Perl » alt.perl » Epoch quest

Vorheriges Thema: day of the week
Nächstes Thema: Help: Snowed on how to pass argument to subroutine