Search code examples
javascriptangularflatpickr

Invalid date provided: Invalid Date


I got the following error form.min.js:1 Error: Invalid date provided: Invalid Date at Object.parseDate (form.min.js:1)

And I am using the flatpickr to pick the date in the input field.

If anyone has the solution please share it with me.

Thanks in Advance.


Solution

  • For Example,

    var testDate;
    var expDate = 04/08/2022;
    
    testDate = new Date(expDate.substr(6, 4), expDate.substr(3, 2) - 1, expDate.substr(0, 2))
    

    It works for me!