3

i try to to use localized dates after 2038 with php

strftime use Timestamp so it doesnt work after 2038

DateTime is not localized...

So I try to use IntlDateFormatter with DateTime :

$d = DateTime::createFromFormat('Y-m-d', '2040-01-01');
$fmt = new IntlDateFormatter(
    'fr_FR',
    IntlDateFormatter::FULL,
    IntlDateFormatter::FULL,
    'America/Los_Angeles',
    IntlDateFormatter::GREGORIAN
);
echo $fmt->format($d);    
echo $fmt->getErrorMessage();

here what I get : datefmt_format: cannot get timestamp: U_ILLEGAL_ARGUMENT_ERROR

Actually i guess IntlDateFormatter internally convert date into timestamp...

So how i can localized date beyond 2038 in php ?

kspal
  • 31
  • 4

1 Answers1

2

we are getting the same problem here. This issue shows up in 32 bit machines, because the formatter changes the DateTime value to a integer timestamp to process it . Dates outside the epoch (1970) +- maxint will give you an error. There are two ways to fix this: 1 - use a 64bit server. 2 - fix PHP IntlDateFormatter

We are going with 1- here, good luck!

(The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer). However, before PHP 5.1.0 this range was limited from 01-01-1970 to 19-01-2038 on some systems (e.g. Windows). Cf : http://php.net/manual/en/function.date.php )

Buisson
  • 479
  • 1
  • 6
  • 23