|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50590 IntlDateFormatter::parse result is limited to the integer range
Submitted: 2009-12-28 12:46 UTC Modified: 2010-09-01 22:53 UTC
From: a dot farhadi at gmail dot com Assigned: stas (profile)
Status: Closed Package: I18N and L10N related
PHP Version: 5.3.1 OS: Ubuntu
Private report: No CVE-ID: None
 [2009-12-28 12:46 UTC] a dot farhadi at gmail dot com
The result of IntlDateFormatter::parse is integer and is limited to the integer range. (i.e. IntlDateFormatter::parse returns The least integer value (e.g. -2147483648 in 32-bit Platforms) when the result is out of the integer range.)

Reproduce code:
$fmt = new IntlDateFormatter("en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL);
var_dump($fmt->parse("Wednesday, January 20, 2038 3:14:07 AM GMT"));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-20 23:55 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: stas
 [2010-06-21 01:42 UTC]
Out of curiosity - how do you expect to use past-2038 timestamps? Many Unix systems won't support those. Do you expect 64-bit value or some other way? float might be not very good for it due to the precision loss.
 [2010-06-21 09:59 UTC] a dot farhadi at gmail dot com
Actually what I want to do is to convert dates between different calendars and to do so I'm using the returned timestamp with IntlDateFormatter::format method as follow:

$df_persian = new IntlDateFormatter('en@calendar=persian', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd');
$df_gregorian = new IntlDateFormatter('en', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd');
echo $df_gregorian->format($df_persian->parse('1388-03-31'));

Hopefully, format method accepts float values as argument and the only problem is parse method which doesn't return past-2038 timestamps.

And by the way float precision loss wouldn't be a problem at least for timestamps up to 14 decimal digits.
 [2010-09-01 22:35 UTC]
Automatic comment from SVN on behalf of stas
Log: Fix bug #50590 - IntlDateFormatter::parse result is limited to the integer range
 [2010-09-01 22:53 UTC]
-Status: Assigned +Status: Closed
 [2010-09-01 22:53 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

 [2010-10-06 19:05 UTC]
Automatic comment from SVN on behalf of cataphract
Log: - Fixed test for bug #50590 on systems with 64-bit longs.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon May 29 10:03:44 2023 UTC