From: mathieuk at gmail dot com Operating system: Mac OSX 10.5 PHP version: 5.3.0alpha1 PHP Bug Type: Feature/Change Request Bug description: [intl] Allow MessageFormatter / IntlDateFormatter to accept DateTime objects?
Description: ------------ Feature request for the new intl extension. Both the MessageFormatter and the IntlDateFormatter accept values for dates. The IntlDateFormatter accepts both Unix timestamps and the value for localtime(). I'm assuming it's the same for the MessageFormatter. Since PHP 5.2 we have the DateTime object through the standard date extension. While it's easy to get the unix timestamp from a DateTime object through DateTime::getTimestamp() introduce in 5.3, this is an extra statement which just adds clutter. Could these two formatters be made to also accept DateTime objects ? Reproduce code: --------------- <?php $date = new DateTime("1 year ago"); $msgfmt = MessageFormatter::create('nl_NL', 'Today one year ago is {0,date}'); echo $msgfmt->format(array($date)); ?> Expected result: ---------------- Output: Today one year ago is 15 aug 2007 Actual result: -------------- Output: Today one year ago is 1 jan 1970 -- Edit bug report at http://bugs.php.net/?id=45829&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45829&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45829&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45829&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45829&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45829&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45829&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45829&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45829&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45829&r=support Expected behavior: http://bugs.php.net/fix.php?id=45829&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45829&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45829&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45829&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45829&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45829&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45829&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45829&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45829&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45829&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45829&r=mysqlcfg