|
Posted by Christoph Burschka on 01/17/07 12:33
Gleep schrieb:
> On Tue, 16 Jan 2007 10:14:53 +0100, Christoph Burschka <christoph.burschka@rwth-aachen.de> wrote:
>
>
>>Christoph Burschka schrieb:
>>
>>>Namely the thirteenth of December 1901, 12:45:52, Pacific Time.
>>>
>>>All dates later than this passed in format "yyyy-mm-dd hh:mm:ss" to the
>>>strtotime function return the correct unix timestamp value (as can be
>>>verified by passing it back to date()).
>>>
>>>If a date earlier than 1901-12-13 12:45:52 is used, it returns an error.
>>>I tried this for a while to find the exact cut-off point, and this is it.
>>>
>>>Any reason - possibly a limitation of the integer value that is used? I
>>>didn't find this documented anywhere...
>>>
>>>--
>>>Christoph Burschka
>>
>>Whoops, I should have checked more closely. In fact this *is* documented
>>as the minimal value of most dates due to the length of the 32-bit integer.
>>
>>I never considered that these "Y2K" problems work backwards, too...
>
>
>
> use this to convert old dates
>
>
> <?php
> function convert_date($text_date){
> $months = array(
> '01' => 'January',
> '02' => 'February',
> '03' => 'March',
> '04' => 'April',
> '05' => 'May',
> '06' => 'June',
> '07' => 'July',
> '08' => 'August',
> '09' => 'September',
> '10' => 'October',
> '11' => 'November',
> '12' => 'December',
> );
>
> $parts = explode("-", $text_date);
> $month = $months[$parts[1]];
> $year = $parts[0];
> $day = $parts[2];
>
> return "$month $day, $year";
> }
>
> echo convert_date('1964-03-22' ); // should output March 22, 1964
>
> ?>
Not actually what I was trying to do - I really do need the Unix timestamp.
Anyway, 1964 shouldn't be a problem as of PHP 5. I don't know precisely
what got changed (I guess they replaced the unsigned with a signed
integer). Since I started using PHP 5, I was able to convert "negative"
dates, which didn't work before. Only years that actually lie outside
the range (1901 to 2038) cause problems.
Hopefully, by the time 2038 arrives, most systems will have the good
sense to switch to 64bit integers...
--
Chris
[Back to original message]
|