gpt4 book ai didi

javascript - 全日历时段持续时间

转载 作者:行者123 更新时间:2023-11-28 05:33:26 25 4
gpt4 key购买 nike

我试图显示从上午 9:30 开始到下午 6:30 结束的时间,其间的时间间隔为 30 分钟.. This question on SO对我来说应该足够了,但是当我尝试时,时间间隔完全从我的完整日历中删除了。这是我的 fullcalendar 代码

 

var dateByColumn = 2;

$(document).ready(function() {

$('#calendar').fullCalendar({
//weekends: false,
//selectable: true,
hiddenDays: [ 0, 6 ],
theme: true,
header: {
left: 'prev,next',
center: 'title',
right: ''
},
defaultView: 'agendaWeek',


viewRender: function(view, $element)
{
$element.find('.fc-event-container').each(function() {


var $this = $(this);
var now = new Date("2016-09-09T09:30:00+05:00");
if(!$this.hasClass('fc-helper-container'))
{

//2 : moday, 3:Tue, 4:Wed, 5:Thu, 6:Fri

for(var i = 0;i<16;i++)
{
var thisDate = $(".fc-day-header:nth-child("+dateByColumn+")").attr('data-date');
var hours = now.getHours();
hours = ('0' + hours).slice(-2);
var min = (now.getMinutes() == 0)?"00":now.getMinutes();
var sec = (now.getSeconds() == 0)?"00":now.getSeconds();
var time = hours+":"+min+":"+sec;
var id = thisDate+"T"+time;
$(this).append('<div class="book" data-date="'+thisDate+'" data-time="'+time+'" id="'+id+'"><a> Book </a></div>');
now.setMinutes(now.getMinutes() + 30);
}
dateByColumn++;
if(dateByColumn >= 7){
dateByColumn = 2;
}


}


});



},

minTime: '09:30:00',
maxTime: '17:30:00',
slotDuration: "00:30:01",
editable: false ,
allDaySlot: false,
eventLimit: true, // allow "more" link when too many events
events: {
url: 'JSON/events_json.php'
}



});
$('body').on('click','.book',function (){
var id = this.id;
var end = new Date(id);
end = end.setMinutes(end.getMinutes() + 30);
var eventData = {
title: "Taken",
start: this.id,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true);});});
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Full Calendar</title>
<link rel='stylesheet' href='http://localhost/fullcalendar/fullcalendar.css' />
<link rel="stylesheet" href="http://localhost/fullcalendar/lib/cupertino/jquery-ui.min.css">

<script src='http://localhost/fullcalendar/lib/jquery.min.js'></script>
<script src='http://localhost/fullcalendar/lib/moment.min.js'></script>
<script src='http://localhost/fullcalendar/fullcalendar.js'></script>
<script src='http://localhost/fullcalendar/lib/jquery-ui.min.js'></script>

</head>
<body>
<div id='calendar'></div>
</body>
</html>

最佳答案

这是我的做法,这只是一种解决方法,不是实际的解决方案,但它对我来说效果很好..

$('tr.fc-minor').each(function(){ // takes the date-time attr for this class
var time = $(this).attr('data-time'); // your input string
var a = time.split(':'); // split it at the colons
var seconds = a[0]+":"+a[1];

console.log(seconds);
$(this).find('.fc-time').html(seconds);
});

关于javascript - 全日历时段持续时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39530037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com