我在我的表单中使用Flatpickr命名为trigger_date
:
.form-group
= label f, :trigger_date, class: "control-label"
= text_input f, :trigger_date, required: true, class: "form-control datetime-picker"
无论我选择哪个日期,表单都将始终提交当前日期和时间。这是我当前设置的Flatpickr
:
const flatpickr = require("flatpickr");
const moment = require("moment");
const $this= $(this)
let defDate = moment().format()
const dateString = $this.val()
if (dateString != NaN && dateString != "NaN" && dateString != null && dateString != undefined && dateString.length > 0) {
defDate = moment().format()
}
const picker = flatpickr($this[0], {
enableTime: true,
defaultDate: defDate,
dateFormat: "Z",
altInput: true,
weekNumbers: true,
minuteIncrement: 1
});