简体   繁体   English

在“周”视图中,添加到日历中的议程很好,但在月视图中,它在美国提前一天

[英]Agenda which is added to the calendar is fine with Week view but in month view it is coming one day earlier in US

I am using FullCalendar to publish an agenda. 我正在使用FullCalendar发布议程。 In full calendar in week view it is displaying the added agenda perfectly but when i am trying to see it in month view it is displaying the added one day before when the agenda has been added. 在周视图的完整日历中,它完美地显示了添加的议程,但是当我试图在月视图中显示时,它在添加议程的前一天显示了添加的议程。 This issue is coming in US time zone only, when i am trying to open it in INDIA the both view are working perfectly fine. 此问题仅在美国时区出现,当我尝试在印度打开时,两种视图都运行良好。

On calendar we are displaying it with 在日历上,我们使用

if (event.vanNumb != undefined) {
                element.find('.fc-title').text('');
                if(event.van == true){

                   var jsDate = new Date(event.start);
                   var today = moment(presentDate);
                   var daysDiff =daysDifference(moment(event.start),today);
                   year    = jsDate.getFullYear ();
                   month   = jsDate.getMonth ();
                   day     = jsDate.getDate ();
                   month      += 1;
                   month   = ("0" + month).slice (-2);
                   day     = ("0" + day)  .slice (-2);

                   if(daysDiff ==0){
                       jQuery('.fc-month-view [data-date="'+year +'-'+ month +'-'+ day+'"]').addClass('fc-today-in-transit');
                   }else{
                       jQuery('.fc-month-view [data-date="'+year +'-'+ month +'-'+ day+'"]').addClass('in-transit');
                   }

                }
              } 

Here is the day difference method 这是日差法

function daysDifference(startDate,endDate){
         return  moment.duration({days: startDate.clone().stripTime().diff(endDate.clone().stripTime(), 'days')});
    }

Please see the issue here 请在这里查看问题 周视图中的图像

月份视图中出现的问题

I am able to solve this issue, hope it will help to others. 我能够解决这个问题,希望对您有所帮助。

Previous code 先前的代码

day     = jsDate.getDate ();

Now 现在

 day     = jsDate.getUTCDate ();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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