[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Strange time output



At 7:18 PM +0100 1/11/00, Martin D. wrote:
>#! perl -w
>
>($day, $month, $year) = (localtime) [3,4,5];
>$timestamp = sprintf("%02d-%02d-%02d\n", $year, $month+1, $day);
>
>print "$timestamp";
>
>this produces:
>100-01-11
>
>Shouldn't it produce:
>00-01-11

Nope...localtime's year is the current year - 1900, so for 2000, that's 100.

-Eric, who made exactly the same mistake two years ago, but didn't 
realize it until last week

--
Eric Albert                     ejalbert@cs.stanford.edu
http://www.stanford.edu/~ejalbert/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org