date_diff
| From: | a_j_bellamy at hotmail dot com | Date: | Thu, 31 Jul 2008 11:59:40 +0000 |
| Subject: | date_diff | ||
| References: | 1 2 3 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969379219@lists.php.net to get a copy of this message | ||
Hi everybody!
This might be the right mailing list and it might not be.
I'm having a problem getting date_diff to work.
I know date_diff accepts 2 DateTime objects and returns a DateInterval which I var_dump but it shows nothing
Help is required!
Regards
Andy
Heres my code:
<?php
$date = new DateTime("28-July-2008");
$other = new DateTime("31-July-2008");
$diff = date_diff($date, $other);
echo '<br />date: ';
var_dump($date);
echo '<br /><br />other: ';
var_dump($other);
echo '<br /><br />diff: ';
var_dump($diff);
echo '<br /><br />get_class_methods - DateInterval : ';
$class_methods = get_class_methods(new DateInterval('P2Y2M2D'));
foreach ($class_methods as $method_name) {
echo "$method_name(), ";
}
echo '<br /><br />get_class_methods - DateTime : ';
$class_methods = get_class_methods(new DateTime("31-July-2008"));
foreach ($class_methods as $method_name) {
echo "$method_name(), ";
}
?>
Heres my output:
date: object(DateTime)#1 (3) { ["date"]=> string(19) "2008-07-28 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
other: object(DateTime)#2 (3) { ["date"]=> string(19) "2008-07-31 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" }
diff: object(DateInterval)#3 (0) { }
get_class_methods - DateInterval : __construct(), format(), createFromDateString(),
get_class_methods - DateTime : __construct(), __wakeup(), __set_state(), createFromFormat(), getLastErrors(), format(), modify(), add(), sub(), getTimezone(), setTimezone(), getOffset(), setTime(), setDate(), setISODate(), setTimestamp(), getTimestamp(), diff(),