From: jo at feuersee dot de Operating system: not OS related PHP version: 5.3.0 PHP Bug Type: I18N and L10N related Bug description: Feature request: native DateTime support in IntlDateFormatter
Description: ------------ The usage of the ICU based IntlDateFormatter class would be much more convenient if it would support DateTime objects, especially the format() method. The workaround is to parse the DateTime value to a timestamp and cast it to int (or use getTimestamp() with PHP 5.3.0+). The alternative localtime() structured param is a bit odd IMHO, I really can't remember having seen any usage of this function in the last 10 years. It seems it has been chosen to circumvent the limited range of timestamps? In fact, the range of localtime() is limited, though not as much as mktime(): with Linux on x686 it's approx. from UTC 1902-01-01 to 2038-01-19 The DateTime class does not have this limited range, a nice OO design, works great with ISO 8601 formatted dates and times . why not use it in IntlDateFormatter? Reproduce code: --------------- 1) php -r '$fmt = new IntlDateFormatter("de_DE" ,IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM, "UTC"); $dt = new DateTime("1781-12-13"); printf("%s\n", $fmt->format($dt));' 2) php -r '$fmt = new IntlDateFormatter("de_DE" ,IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM, "UTC"); $dt = new DateTime("1781-12-13"); printf("%s\n", $fmt->format($dt->format("U")));' 3) php -r '$fmt = new IntlDateFormatter("de_DE" ,IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM, "UTC"); $dt = new DateTime("1781-12-13"); printf("%s\n", $fmt->format((int) $dt->format("U")));' Expected result: ---------------- 1) 12.12.1781 23:00:00 2) 12.12.1781 23:00:00 3) 12.12.1781 23:00:00 Actual result: -------------- 1) 2) 3) 12.12.1781 23:00:00 -- Edit bug report at http://bugs.php.net/?id=49609&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49609&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49609&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49609&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49609&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49609&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49609&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49609&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49609&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49609&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49609&r=support Expected behavior: http://bugs.php.net/fix.php?id=49609&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49609&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49609&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49609&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49609&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49609&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49609&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49609&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49609&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49609&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49609&r=mysqlcfg