【问题标题】:How to Display Current Month's Calendar Starting With Today's Date in React JS Full Calender如何在 React JS 完整日历中显示从今天开始的当前月份日历
【发布时间】:2021-05-26 05:02:23
【问题描述】:

我想在当前月份的日历的开始日期显示今天的日期,为此使用了@fullcalendar/react 插件。请查看附件。 如果有人可以帮助我,我将不胜感激。 enter image description here

【问题讨论】:

    标签: reactjs react-redux react-hooks fullcalendar fullcalendar-5


    【解决方案1】:

    我想我知道如何在本地做到这一点

    您可以使用以下逻辑使其动态化

    const unixTime = Date.now();
    console.log(unixTime) // UNIX Epoch Timestamp
    const date = new Date(unixTime);
    const currentDOW = date.getDay();
    // if you console.log currentDOW it outputs 3 --> Wednesday
    

    似乎 DOW(星期几)默认为 0(星期日)。因此,您应该能够将呈现的第一个框动态设置为返回的 currentDOW 值(0-6,或星期日-星期六),以每天更新当前的 firstDay。

    【讨论】:

    • 我可以知道我必须在哪里写这段代码意味着fullcalender插件的任何回调函数吗? @andrew-ross
    • 我相信是这样,基于文档。如果您使用 currentDOW 常量,getDay 值将每天更新,该常量返回一个与应用程序部署所在时区的任何一天相对应的数字
    • 我尝试了上述逻辑,但显示不正确。请查看此屏幕截图。 prnt.sc/13fr71oprnt.sc/13fr9nm
    • 还有其他替代方式吗? @andrew-ross
    猜你喜欢
    • 2013-07-23
    • 2016-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-23
    • 2013-05-05
    • 1970-01-01
    相关资源
    最近更新 更多