PHP 日期时间间隔错误

PHP DateTime Interval errors

if (empty($krow['BUSSTRT'])){ 
    $busts = $ts->add(new DateInterval('PT6i5s'));
    $busDate = $busts->format('m/d/Y H:i:s');
    echo "busDate:".$busDate."<br>\n";
}else{
    $busts = new DateTime($krow['BUSSTRT']);
    $busDate = $busts->format('m/d/Y H:i:s');
    echo "busSTRT:".$busDate."<br>\n";
}   

if (empty($krow['LAMISTRT'])){ 
    echo "lamistrt is empty::::";
    $lamts = $busts->add(new DateInterval('PT11is'));
    $lamDate = $lamts->format('m/d/Y H:i:s');
    echo "lamDate:".$lamDate."<br>\n";
}else{
    $lamts = new DateTime($krow['LAMISTRT']);
    $lamDate = $lamts->format('m/d/Y H:i:s');
    echo "lamistrt:".$lamDate."<br>\n";
} 

上面的代码抛出以下错误:

PHP Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (PT11i3s)'

$bustDate 是:

busSTRT:02/06/2015 03:53:56 lamistrt 为空:::::

我在这里错过了什么?

当使用 DateInterval() 创建间隔时,您使用 M 分钟,而不是 i。此外,如果没有秒,则必须从间隔声明中省略它:

$busts = $ts->add(new DateInterval('PT6M5S'));
$lamts = $busts->add(new DateInterval('PT11M'));

i用于获取日期间隔的分钟数:

echo $intervalObj->i; // get minutes