Reputation: 11
I've looked at other questions about the same error but I'm having trouble applying them to my situation.
This is the error I'm getting:
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [datetime.--construct]: Failed to parse time string (2013-07-22164:50:00) at position 10 (1): Unexpected character' in /Applications/XAMPP/xamppfiles/htdocs/Festival_Planner/index.php:88 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/Festival_Planner/index.php(88): DateTime->__construct('2013-07-22164:5...', Object(DateTimeZone)) #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/Festival_Planner/index.php on line 88
This is the for loop with the line that's generating the error:
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);
}
And this is a similar for loop that DOES work, using exactly the same code structure as I did on line 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>
';
}
Upvotes: 1
Views: 6517
Reputation: 13535
you need to have a space between date and time
$time = new DateTime($ocurrentscreening->date.' '.$ocurrentscreening->starttime,new DateTimeZone('Pacific/Auckland'));
Upvotes: 1