Note that there are some explanatory texts on larger screens.

plurals
  1. POFullCalendar not displaying time from JSON events
    text
    copied!<p>Greetings,</p> <p>Using FullCalendar (<a href="http://arshaw.com/fullcalendar/" rel="nofollow noreferrer">http://arshaw.com/fullcalendar/</a>) to pull events from a MySQL database table via JSON. The events are being displayed in the calendar but for some reason it is ignoring the time (hours, minutes, seconds) of the event. Here is the Javascript from the calendar page -</p> <pre><code>&lt;script type='text/javascript'&gt; $(document).ready(function() { $('#calendar').fullCalendar({ editable: false, events: "json-events.php", eventDrop: function(event, delta) { alert(event.title + ' was moved ' + delta + ' days\n' + '(should probably update your database)'); }, loading: function(bool) { if (bool) $('#loading').show(); else $('#loading').hide(); } }); }); &lt;/script&gt; </code></pre> <p>and my JSON PHP file (note that I am including the time after the date, presently that field is set as DATE only):</p> <pre><code>&lt;?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/pdo_conn.inc.php'; $getEventsSQL = $db-&gt;query("SELECT id, title, date_start AS start, date_end AS end FROM training"); $events = array(); while ($row = $getEventsSQL-&gt;fetch()) { $start = $row['start']; $end = $row['end']; $title = $row['title']; $eventsArray['id'] = $row['id']; $eventsArray['title'] = $title; $eventsArray['start'] = $start . " 13:00:00"; $eventsArray['end'] = $end . " 14:00:00"; $eventsArray['url'] = "http://somewhere.org"; $events[] = $eventsArray; } echo json_encode($events); ?&gt; </code></pre> <p>The above outputs: </p> <pre><code>[{"id":"13","title":"Test 1","start":"2010-05-18 13:00:00","end":"0000-00-00 14:00:00","url":"http:\/\/tapp-essexvfd.org"},{"id":"14","title":"Test 2","start":"2010-06-18 13:00:00","end":"2010-06-19 14:00:00","url":"http:\/\/tapp-essexvfd.org"},{"id":"15","title":"Test 3","start":"2010-06-18 13:00:00","end":"0000-00-00 14:00:00","url":"http:\/\/somewhere.org"},{"id":"16","title":"test4","start":"2010-05-03 13:00:00","end":"0000-00-00 14:00:00","url":"http:\/\/somewhere.org"}] </code></pre> <p>Thanks!</p> <p><strong>Edit</strong></p> <p>Here is the modified PHP to reflect the accepted solution. Thanks!</p> <pre><code> &lt;?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/pdo_conn.inc.php'; $getEventsSQL = $db-&gt;query("SELECT id, title, date_start AS start, time FROM events WHERE date_start &gt;= NOW() AND status = 1"); $events = array(); while ($row = $getEventsSQL-&gt;fetch()) { $start = $row['start']; $title = $row['title']; $eventsArray['id'] = $row['id']; $eventsArray['title'] = $title; $eventsArray['start'] = $start . " " . $row['time']; $eventsArray['end'] = $end; $eventsArray['url'] = "#"; $eventsArray['allDay'] = false; $events[] = $eventsArray; } echo json_encode($events); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload