i using php send data fullcalendar, calendar dates display invalid date or nan
see date formatting below, ideas how fix this?
php
foreach ($dates $key => $date) { //$date->getdate() 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 using:
$da = date('y-m-d h:i:s', $date->getdate()); $datetimea = new datetime($da); $array[$key]['start'] = $datetimea->format(datetime::iso8601);
it because date formatted incorrectly, firefox require utc format work, is:
yyyy + '-' + mm + '-' + dd + 't' + hh + ':' + min + 'z'; behing yyyy year formatted @ 4 digits, mm month formatted @ 2 digits (january - 00, 0 important), dd day formatted @ 2 digits, hh hour formatted @ 2 digits , min minutes formatted @ 2 digits.
t , z constants.
so change format if want hours , minutes:
$array[$key]['start'] = $start->format('y-m-d\th:i:s\z'); $array[$key]['end'] = $end->format('y-m-d\th:i:s\z'); hope works. tell me if doesn't , try solve :)
Comments
Post a Comment