【问题标题】:Using PHP date as a Pikaday minDate variable使用 PHP 日期作为 Pikaday minDate 变量
【发布时间】:2020-06-11 09:22:28
【问题描述】:

我正在尝试在 Pikaday 中使用 php 日期变量,但运气不佳。

PHP 日期:

$creation_date = date("d/m/Y", strtotime($rows['creation_date']));

皮卡迪代码:

startPicker = new Pikaday({
    field: document.getElementById('task_start_date'),
    format: 'DD/MM/YYYY',
    minDate: <?php echo $creation_date; ?>,
    onSelect: function() {
        startDate = this.getDate();
        updateStartDate();
    }
})

我猜我需要格式化日期?而且我认为需要更改月份,以便 1 月为 00,2 月为 01 等,但不能 100% 确定。

【问题讨论】:

    标签: php pikaday


    【解决方案1】:

    就像写在document :minDate the minimum/earliest date that can be selected (this should be a native Date object - e.g. new Date() or moment().toDate())。所以你需要给出正确的 php 日期格式。

    这个问题已经是答案here

    echo date('D M d Y H:i:s O');

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-22
      • 2017-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多