简体   繁体   中英

Fullcalendar : Wrong end time displayed for events

I have an array of events which is here : 在此处输入图片说明

And this is my fullcalendar : 在此处输入图片说明

As you can see the end time is never the same as the array , but the start time is good, why?

What I have tried : timezone : local
ignoreTimeZone : true

I didn't have effects on the rendering.

Note : the data is fetched in my database, the date are standard DATETIME format and it is json encoded in my php file.

I think it may be because I need to parse somehow my fields but I don't know how to do it.

this is my code :

$html .= '<div id="calendar"></div>';



            // PROCEDURE SQL
            $sql2 = "SELECT DISTINCT id, event_titre as 'titre', event_start as 'start', event_stop as 'stop' FROM tmp;";

            //CALL WITH SESSION VARS
            if(!$mysqli->query("CALL diff('". $_SESSION['upcNameId']." ', '". $_SESSION['statDateFrom'] ." 00:00:00','". $_SESSION['statDateTo'] ." 00:00:00');"))
                die($mysqli->error);

            //EXEC SQL2
            $result = $mysqli->query($sql2)
                or die($mysqli->error);

            $i=0;
            $events = array();
            while ($row = $result->fetch_assoc()) {
                $events[] = $row;
            }

            $buildingevents = json_encode($events);
            //echo json_encode($events);


$html .= "<script src='/wp-content/plugins/biobelt/moment.min.js'></script>
        <script src='/wp-content/plugins/biobelt/fullcalendar.min.js'></script>
        <link rel= 'stylesheet' href='/wp-content/plugins/biobelt/fullcalendar.css' type='text/css'>
        <script src='/wp-content/plugins/biobelt/fr.js'></script>
        <script>
            jQuery(document).ready(function() {
                var bevents = ".$buildingevents."
                console.log(bevents)
                jQuery('#calendar').fullCalendar(
                    {
                        header: {
                            right: 'today, month, agendaDay, agendaWeek, prev, next'
                        },
                        defaultDate: '" . $_SESSION['statDateFrom'] ."',
                        events: bevents,
                        timezone: 'local',
                    });
            });
        </script>"; 

Your events do not match the expected fields of an Event object: see documentation here

Replace the aliases in your query:

titre by title

and

stop by end

and it should be good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM