javascriptphpjsonfullcalendar

fullcalendar json add start and end times to dates


is it possible to display start & end times on full calendar latest version? I am using json to feed the data as such, this works fine:

// Initializes a container array for all of the calendar events
$jsonArray = array();
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
 $id = $row['HolidayType'];
 $title = $row['name'];
 $start = $row['start'];
 $end = $row['end'];
 // Stores each database record to an array
 $buildjson = array('title' => "$title", 'start' => "$start", 'end' => "$end", 'allDay' => false);
 // Adds each array into the container array
 array_push($jsonArray, $buildjson);
}

echo json_encode($jsonArray);

In my db I added 2 columns, start_time & end_time, if I add those to above code it doesnt pull times through and page errors?

// Initializes a container array for all of the calendar events
$jsonArray = array();
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
 $id = $row['HolidayType'];
 $title = $row['name'];
 $start = $row['start'];
 $end = $row['end'];
 $start_time = $row['start_time'];
 $end_time = $row['end_time'];

 // Stores each database record to an array
 $buildjson = array(
 'title' => "$title",
 'start' => "$start",
 'end' => "$end",
 'start_time' => "$start_time",
 'end_time' => "$end_time",
 'allDay' => false);
 // Adds each array into the container array
 array_push($jsonArray, $buildjson);
}

echo json_encode($jsonArray);

Any ideas how I would pull the time through via json, using start_time, end_time is obviously incorrect?


Solution

  • Gary, do your start and end params not contain times? Out of the box Fulcalendar will display the start time using the default timeFormat:'h(:mm)t' which if you look at the example demos on FulCalendar's site show as 7p or 10:30a for example. You do need to use allDay:false for this to happen.

    As for showing both start and end dates. I could not find anything that would do that directly out the box. I ended up modifying the code (somewhere around line 4700 for the month display and got the event block to display solething like this...

    07:00 title 10:30

    If your start and end params don't contain time the you should be able to use the extra values in your array by using event.start_time and event.end_time, but again you will need to modify the main FulCalendar.js

    If you need any more info let me know.