2

我正在尝试下面的代码..集成全日历:-

<doctype! html>
    <html lang="urf-8">
    <head>
    <title>Full calendar</title>
    <link rel="stylesheet" href="fullcalendar.css"/>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css"/>
    <script type='text/javascript' src='jquery.js'></script>
    <script type='text/javascript' src='fullcalendar.js'></script>
    <script>
    $(document).ready(function() {
        $('#cal').fullCalendar({
            // put your options and callbacks here
            theme: true,
            header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,basicWeek,basicDay,agendaWeek,agendaDay'
                    },
            editable: false,
            events: "json-events.php",
    })
    });

    </script>
    </head>
    <body>
        <div id="cal" ></div>
    </body>
    </html>

Json-events.php 代码:-

<?php
    include("connect.php");
    $query = "select * from calendar";

    $res = mysql_query($query) or die(mysql_error());
    $events = array();
    while ($row = mysql_fetch_assoc($res)) {
        $eventsArray['id'] =  $row['calendar_id'];
        $eventsArray['title'] = $row['subject'];
        $eventsArray['start'] = mktime($row['start_date_time']);
        $events[] = $eventsArray;
    }
    echo json_encode($events);
    ?>

为了在我访问 json-events.php 时进行调试,我得到了结果,但在 fullcalendar 中没有显示任何事件。

请帮我..

4

1 回答 1

4

问题在于 JSON 中日期字符串的格式。格式与插件的日期格式不兼容。如果您使用strtotime()php 转换为 UNIX 时间戳,它们将起作用。

于 2012-11-25T06:08:07.900 回答