Edit report at http://bugs.php.net/bug.php?id=45829&edit=1

 ID:                 45829
 Updated by:         s...@php.net
 Reported by:        mathieuk at gmail dot com
 Summary:            [intl] Allow MessageFormatter / IntlDateFormatter to
                     accept DateTime objects?
 Status:             Assigned
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   Mac OSX 10.5
 PHP Version:        5.3.0alpha1
 Assigned To:        stas
 Block user comment: N

 New Comment:

Yes, this is on the TODO list (contributions welcome! :)


Previous Comments:
------------------------------------------------------------------------
[2008-08-16 16:09:15] mathieuk at gmail dot com

Additionally, MessageFormatter::parse() might return a DateTime object 

instead of a UNIX timestamp.

------------------------------------------------------------------------
[2008-08-15 06:13:57] mathieuk at gmail dot com

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 this bug report at http://bugs.php.net/bug.php?id=45829&edit=1

Reply via email to