简体   繁体   中英

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. 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 ();

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