【问题标题】:FullCalendar dayRender is showing the next days date?FullCalendar dayRender 显示下几天的日期?
【发布时间】:2015-11-29 08:27:29
【问题描述】:

我将FullCalendar 用于医生/患者预约系统。我想使用 FullCalendar 在患者屏幕上显示医生的可用性。我正在使用dayRender 函数,但它是否向我显示了第二天的日期,特别是针对 EST 时区。谁能告诉我我在这里错过了什么?

dayRender: function (date, cell) {
            var view = $('#calendar').fullCalendar('getView');
            var strDay = moment(date._d).format('YYYY-MM-DD');
                $.ajax({
                    url: '/client/profile/ajaxexpertappointentclientday',
                    data: 'strDate='+strDay ,
                    type: "POST",
                    async:false,
                    success: function(intFlag) {
                        var today = moment();
                        if(intFlag == 1 && strDay >= strTodaysDate && strDay < moment(today._d).add('days', 2).format('YYYY-MM-DD')) {
                            cell.css("background-color", "red");
                        } else {
                            cell.css("background-color", "#F0F0F0");
                        }
                    }
                });
            }
        },

【问题讨论】:

  • 您能否在您的问题中添加日历库的链接?其他人可以帮助您。

标签: javascript jquery timezone fullcalendar


【解决方案1】:

我不知道您使用了多少 fullCalendar。 我用过这个http://fullcalendar.io/

代码示例 javascript

        $('#calendar').fullCalendar(
        {
            timeFormat: {
                agenda: 'H(:mm){ - H(:mm)}',
                '': 'H(:mm){-H(:mm) }'
            },
            aspectRatio: 2,
            selectable: true,
            selectHelper: true,
            editable: false,
            theme: false,
            eventColor: '#bcdeee',
            eventSources: [
                {
                    url: '/index.php',
                    type: 'POST',
                    data:
                    {
                        controller  : "engineers",
                        action      : "getCalendar"
                    },
                    error: function()
                    {
                        alert('there was an error while fetching events!');
                    }
                }
            ],
            loading: function(bool) {
                $('#loading').toggle(bool);
            },
            eventClick: function(event)
            {
                // opens events in a popup window
                window.open("?controller=audits&action=show&id="+event.id, '_blank').focus();
                return false;
            },
        });

并且服务器的响应必须是这样的:

    [{"id":61,"title":"BOLOGNA (Bologna)","start":"2015-08-30 15:00:00+01:00","end":"2015-08-31 15:00:00+01:00","allDay":false,"color":null}]

如果在响应 JSON 上设置了颜色属性,将是特定事件的颜色。

http://fullcalendar.io/docs/event_rendering/eventColor/

您可以使用任何 CSS 颜色格式,例如 #f00、#ff0000、 rgb(255,0,0) 或红色。

【讨论】:

  • 我得到了答案,而不是使用 moment(date._d).format('YYYY-MM-DD'),最好将其转换为 UTC 日期,就像我所做的那样 moment.utc(date. _d).format('YYYY-MM-DD');
  • ajay,将它转换为 utc 对我也有用,谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-19
  • 2013-07-23
  • 2015-04-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多