I am using php to send some data to fullcalendar, but the calendar dates display as Invalid Date
or NaN
see the date formatting below, any ideas how to fix this?
PHP
foreach ($dates as $key => $date) {
//$date->getDate() is a timestamp
$start = new DateTime($date->getDate());
$end = new DateTime($date->getDate() + 1800);
$array[$key]['start'] = $start->format('c');
$array[$key]['end'] = $end->format('c');
}
JavaScript
$calendar.fullCalendar({
header : h,
defaultView: 'month',
slotMinutes: 15,
editable : false,
droppable : false,
events : {
url : '/api',
type: 'POST',
data: data
}
});
edit:
I end up using:
$dA = date('Y-m-d H:i:s', $date->getDate());
$datetimeA = new DateTime($dA);
$array[$key]['start'] = $datetimeA->format(DateTime::ISO8601);