我已经查看了有关同一错误的其他问题,但我无法将它们应用于我的情况。
这是我得到的错误:
致命错误:未捕获的异常 'Exception' 带有消息 'DateTime::__construct() [datetime.--construct]:无法在位置 10 (1) 解析时间字符串 (2013-07-22164:50:00):意外字符' 在 /Applications/XAMPP/xamppfiles/htdocs/Festival_Planner/index.php:88 堆栈跟踪:#0 /Applications/XAMPP/xamppfiles/htdocs/Festival_Planner/index.php(88): DateTime->__construct('2013-07 -22164:5...', Object(DateTimeZone)) #1 {main} 在第 88 行的 /Applications/XAMPP/xamppfiles/htdocs/Festival_Planner/index.php 中抛出
这是带有生成错误的行的 for 循环:
for($iCount2=0;$iCount2<count($ascreenings);$iCount2++){
$ocurrentscreening = $ascreenings[$iCount2];
///////// THIS IS LINE 88:
$time = new DateTime($ocurrentscreening->date.''.$ocurrentscreening->starttime,new DateTimeZone('Pacific/Auckland'));
$displayTime = date_format($time, 'g:ia');
$sLabel = $ocurrentscreening->date.', '.$displayTime.'.';
$oForm->makeCheckBox("screening".$ocurrentscreening->screeningid, $sLabel, $ocurrentscreening->screeningid);
}
这是一个类似的 for 循环,它确实可以工作,使用与我在第 88 行所做的完全相同的代码结构。
for($iCount=0;$iCount<count($aUsersScreenings);$iCount++){
$odisplayedscreening = $aUsersScreenings[$iCount];
$ofilm = new film();
$ofilm->load($odisplayedscreening->filmid);
$title = $ofilm->title;
$time = new DateTime($odisplayedscreening->date.''.$odisplayedscreening->starttime,new DateTimeZone('Pacific/Auckland'));
$displayTime = date_format($time, 'g:ia');
$sHTML .= '
<div class="selected" id="screening'.$odisplayedscreening->screeningid.'">
<span>'.$title.'</span>.'.$displayTime.'.
</div>
';
}