#48609 [Com]: DateInterval::format() doesn't work
| From: | yoarvi at gmail dot com | Date: | Tue, 08 Dec 2009 10:44:29 +0000 |
| Subject: | #48609 [Com]: DateInterval::format() doesn't work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-145517@lists.php.net to get a copy of this message | ||
ID: 48609
Comment by: yoarvi at gmail dot com
Reported By: pierre dot inglebert at insa-rennes dot fr
Status: Open
Bug Type: Date/time related
Operating System: Debian Lenny
PHP Version: 5.3.0RC4
New Comment:
According to the documentation for DateInterval::format
(http://us.php.net/manual/en/dateinterval.format.php), the format
specifiers need to be prefixed with a %.
var_dump($diff->format('%H:%i:%s'));
var_dump($diff->format('%Y-%m-%d %H:%i:%s'));
produces the expected result.
Previous Comments:
------------------------------------------------------------------------
[2009-06-19 17:19:19] pierre dot inglebert at insa-rennes dot fr
Description:
------------
DateInterval::format method just returns the parameter given.
Reproduce code:
---------------
<?php
$date1 = new DateTime('2009-06-19 20:00:00');
$date2 = new DateTime('2009-06-19 20:00:40');
$diff = $date1->diff($date2,TRUE);
print_r($diff);
var_dump($diff->format('H:i:s'));
var_dump($diff->format('Y-m-d H:i:s'));
?>
Expected result:
----------------
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 40
[invert] => 0
[days] => 0
)
string(5) "00:00:40"
string(11) "0000-00-00 00:00:40"
Actual result:
--------------
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 40
[invert] => 0
[days] => 0
)
string(5) "H:i:s"
string(11) "Y-m-d H:i:s"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48609&edit=1