[thelist] Date returning 20100 - second try
Anthony Baratta
Anthony at Baratta.com
Thu Jun 29 19:54:43 CDT 2000
CDitty wrote:
>
> Haven't seen this come through yet. Please forgive if this is a dup.
>
> Can someone tell me why this routine is returning 20100 instead of 2000?
>
> @date = localtime(time); #puts the current time/date into an array
> $day = $date[3] + 1; #have to add 1 since it returns days starting at 0
> $month = $date[4] + 1; #same with the month
> $yr = "20" . $date[5]; #only returns a 2 digit year, change 19 to 20
> after y2k
> print "$yr\n";
Because $date[5] is sending 100 instead of 00.
What I do (since this looks like perl):
if ($date[5] > 99) {
$yr = 1900 + $date[5];
} else {
$yr = "20" . $date[5];
}
--
Anthony Baratta
President
KeyBoard Jockeys
South Park Speaks Version 3 is here!!!
http://www.baratta.com/southpark
Powered by Tsunami
More information about the thelist
mailing list