[thelist] Date returning 20100 - second try

Steven Champeon schampeo at hesketh.com
Thu Jun 29 23:46:20 CDT 2000


on Thu, Jun 29, 2000 at 05:33:40PM -0700, Anthony Baratta wrote:
> 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];
> }

Of course, there's nothing wrong with just /adding/ the result to 1900
in any case, like so:

$yr = 1900 + $date[5];

...since $date[5] is always the number of years since 1900. The reason
this whole date handling thing becomes a problem is that people assume
the value of $date[5] is only a two-digit string and prefix it with
the two-digit century string. Your solution as listed above causes a
Year 2100 problem. ;) In 2100, provided that the world doesn't end
when time_t rolls over, $yr will be equal to 20100 and you'll be back
in the same situation you were in before.

Steve

-- 
http://a.jaundicedeye.com/weblog/
because it just annoys people when I talk to myself...




More information about the thelist mailing list