[thelist] Date returning 20100

Jeremy Ashcraft ashcraft at 13monkeys.com
Mon Jul 3 10:55:31 CDT 2000


Yeah, localtime() returns the number of years since 1900, no the two digit year.
Just change

$yr = "20".$date[5];

to

$yr = 1900 + $date[5];

and everything should be fine.

HTH

CDitty wrote:

> 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";
>
> Thanks
>
> CDitty
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !

--
Jeremy Ashcraft
http://www.webhack.com
http://www.13monkeys.com
---------------------------------------
I had a handle on life, but it broke...
---------------------------------------






More information about the thelist mailing list