gpt4 book ai didi

javascript - fullcalendar 如何将 titleFormat 设置为 m/d/yyyy - m/d/yyyy

转载 作者:行者123 更新时间:2023-11-30 11:44:04 25 4
gpt4 key购买 nike

如何设置 titleFormat 使日历的标题看起来像1/9/2017 - 1/13/2017(没有周六和周日,只有周一到周五)目前我的日历在开始时看起来像这样,标题看起来像 1/9 – 15/2017(这不是我想要的)

  $('#calendar').fullCalendar({

header: {
left: 'prev title next today',
right: ''
},
weekends: false,
titleFormat: "M/D/Y",
editable: false,
firstDay: 1,
disableDragging: true,
displayEventEnd: true,
views: {
week: {
type: 'basicWeek',
duration: {
days: 7
},
columnFormat: 'dddd M/D/Y'// Format the day to show full weekday and its date
}
},

请协助。

最佳答案

您可以使用 viewRender 属性创建自己的标题格式。

首先,您必须将 titleFormat 更改为如下所示:

titleFormat: "YYYY/MM/DD"

标题现在应该是这样的:

2018/05/27 – 2018/06/02

然后您可以使用 viewRender 属性重新格式化标题,如下所示:

 viewRender: function (view, element) {

//reformat title date for week mode
if (view.type == "agendaWeek") {

//Get the start date value and reformat the date
var startDate = moment(view.title.split("–")[0].replace(" ", "")).format("M/D/YYYY");

//You can set the day range depending on what you need
//If you only want to show dates from Monday to Friday, then you can get the end date value by adding 4 days from the start date
var endDate = moment(startDate).add(4, "days").format("M/D/YYYY");

//Override the fullcalendar title here
$(".fc-center h2").text(startDate + " – " + endDate);
}

}

您可以在此处阅读第二个问题的答案: FullCalendar show only weekDays

关于javascript - fullcalendar 如何将 titleFormat 设置为 m/d/yyyy - m/d/yyyy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41593809/

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