PHP how can I localize a date after 2038
I am trying to use localized dates after 2038 with php
strftime use Timestamp so it doesn't work after 2038
DateTime is not localized ...
So I am trying 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 is what I get: datefmt_format: Can't get timestamp: U_ILLEGAL_ARGUMENT_ERROR
Actually my guess is that the IntlDateFormatter internally converts the date to a timestamp ...
So how can I localize a date outside of 2038 in php?
source to share
we get the same problem. This issue occurs on 32-bit machines because the formatter changes the DateTime value to an integer timestamp to handle it. Dates out of epoch (1970) + - maxint will give you an error. There are two ways to fix this: 1 - use a 64-bit server. 2 - fix PHP IntlDateFormatter
We're going with 1- here, good luck!
(Valid timestamp range is typically Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT (These are the dates corresponding 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 )
source to share