最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Full calendar: On click of time slot wrong time selected - Stack Overflow

programmeradmin0浏览0评论

I have used full calender in my project. DefaultView is weekview.

In week view when click in between 5pm to 6pm(Date:21-11-2015) timeslot, it gives perfect time slot timing with 21-11-2015 5:00pm to 6:00pm.But when i click on 7pm to 8pm(Date:21-11-2015) timeslot it gives me wrong time with 22-11-2015 7:00pm to 8:00pm.

I don't know how date change to next day. Actual date must be 21-11-2015 7:00pm to 8:00pm.

My timezone is Asia/Kolkata (GMT+05:30).

I have used full calender in my project. DefaultView is weekview.

In week view when click in between 5pm to 6pm(Date:21-11-2015) timeslot, it gives perfect time slot timing with 21-11-2015 5:00pm to 6:00pm.But when i click on 7pm to 8pm(Date:21-11-2015) timeslot it gives me wrong time with 22-11-2015 7:00pm to 8:00pm.

I don't know how date change to next day. Actual date must be 21-11-2015 7:00pm to 8:00pm.

My timezone is Asia/Kolkata (GMT+05:30).

Share Improve this question edited Nov 18, 2015 at 6:47 Dhara asked Nov 18, 2015 at 6:11 DharaDhara 1,4815 gold badges30 silver badges48 bronze badges 1
  • 1 some code or JSfiddle may be... – Minato Commented Nov 18, 2015 at 6:39
Add a ment  | 

1 Answer 1

Reset to default 8

Finally i got solution.

dayClick: function(date, allDay, jsEvent, view)
{
       alert(date); // Gives Sat Nov 21 2015 19:00:00 GMT+0000
}

Here date gives me Sat Nov 21 2015 19:00:00 GMT+0000. And my timezone is Asia/kolkata (GMT+05:30). so it automatically add 05:30 hours to 19:00:00. So date is converted to next day.

For this problem i do following process.

dayClick: function(date, allDay, jsEvent, view)
    {

var tzDifference = date.getTimezoneOffset() //this gives me timezone difference of local and UTC time in minutes
var offsetTime = new Date(date.getTime() + tzDifference * 60 * 1000); //this will calculate time in point of view local time and set date
    }

And i get date which i want.

发布评论

评论列表(0)

  1. 暂无评论