【问题标题】:Fullcalendar Moment: Getting current time plus 2 hoursFullcalendar Moment:获取当前时间加上 2 小时
【发布时间】:2015-11-21 03:31:50
【问题描述】:

这应该很简单...使用带有 Fullcalendar 的 moment.js,我需要获取当前时间并添加两个小时。

在 select: 方法(或任何你称之为的方法)中,我有:

select: function(start, end) {

“开始”参数包含当前时间。 End 似乎包含同样的东西。如果我单击添加事件,它会详细说明当前时间到当前时间 + 30 分钟。我需要做的是结束当前时间+ 2小时。我查看了各种文档,但没有找到任何关于做类似事情的参考……所以我是盲人(可能)或者它丢失了。请帮忙? :)

【问题讨论】:

    标签: javascript jquery fullcalendar


    【解决方案1】:

    您可以克隆开始日期并添加 2 小时 http://jsfiddle.net/0fuhhh7v/1/

    var end = start.clone().add(2,'hour');
    

    对于fullCalendar中的选择

    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'agendaWeek,agendaDay'
        },
        defaultView: 'agendaWeek',
        defaultDate: '2015-11-01',
        selectable: true,
        select: function (start, end) {
            end = start.clone().add(2, 'hour');
            alert('Time block is between ' + start.format() + ' and ' + end.format());
            $('#calendar').fullCalendar('unselect');
        },
        editable: true
    });
    

    【讨论】:

      猜你喜欢
      • 2018-04-17
      • 2013-09-18
      • 2021-04-14
      • 1970-01-01
      • 1970-01-01
      • 2013-12-20
      • 2010-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多