DateInterval对象 - “d”和“天”

时间:2016-11-14 12:47:39

标签: php dateinterval

我有以下功能:

    <?php
$date1="2013-10-11";
$date2="2013-12-12";

$objDateEnd = new DateTime($date2);
$objDateStart = new DateTime($date1);
//var_dump($objDateStart);

$xx = $objDateEnd->format('Y')*360 + $objDateEnd->format('m')*30 + (($objDateEnd->format('d') == 31)?30:$objDateEnd->format('d')) -
                                               ($objDateStart->format('Y')*360 + $objDateStart->format('m')*30 + (($objDateStart->format('d') == 31)?30:$objDateStart->format('d')))
                                               + 1;
//$yy = new DateInterval('P'.$xx.'d');
$yy= DateInterval::createFromDateString('222 days');
//echo  $yy->format('%d days');
echo "1st \n";
print_r ($yy);

echo "2nd \n";

$diff=date_diff($objDateStart,$objDateEnd);
print_r ($diff);

?>

为什么第一个DateInterval对象将值[d] => 222和第二个DateInterval对象返回为[days] => 62

为了让“222”出现在“[days]”标签中需要更改哪些内容?

0 个答案:

没有答案