【问题标题】:Flatpickr calendar show wrong default dateFlatpickr 日历显示错误的默认日期
【发布时间】:2018-01-25 16:10:05
【问题描述】:

我在 wordpress 中安装了 facetwp,搜索完成后,搜索小部件未显示搜索前选择的正确日期

如何通过 javascript 覆盖此显示问题(选定日期)?

查看实际问题:https://www.sweetpictures.com.my/product-category/photographers/?fwp_photo=2018-01-31%2C2018-01-31%2C1&fwp_productcategory=ampang&fwp_expertise=wedding-reception

假设日历选择器选择的日期是 2018 年 1 月 31 日 但它显示的是 2018 年 8 月 20 日

感谢您的帮助和帮助

【问题讨论】:

    标签: date calendar facet flatpickr


    【解决方案1】:

    使用 Flatpickr 的文档将默认日期设置为您想要的日期:https://chmln.github.io/flatpickr/examples/#supplying-dates-for-flatpickr

    这样您就可以将以下参数添加到您的 flatpickr 实例中:

    //example with jQuery
    $('#your-date-element').flatpickr({
       minDate: 'today',
       dateFormat: 'd/m/Y'
    })
    

    如果这不起作用,请尝试使用 flatpickr 实例中的 onReady 函数将输入设置为好日期:

    //example with jQuery
    $('#your-date-element').flatpickr({
        minDate: 'today',
        dateFormat: 'd/m/Y',
        onReady: function (selectedDates, dateStr, instance) {
            $('#your-date-element input').val(
                instance.formatDate(new Date(), 'd/m/Y')
            )
        },
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-12
      • 2019-11-22
      • 1970-01-01
      • 1970-01-01
      • 2016-01-04
      • 1970-01-01
      • 1970-01-01
      • 2015-05-31
      相关资源
      最近更新 更多