Flatpickr always saves the current datetime

I'm using Flatpickr for a field in my form called trigger_date:

  = label f, :trigger_date, class: "control-label"
  = text_input f, :trigger_date, required: true, class: "form-control datetime-picker"

No matter which date I pick the form will always submit the current date and time. This is my current setup of 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



Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.