Search code examples
javascriptjquerydatedatejs

Date.parseExact doesn't give accurate result


I am consuming "date.js" and "en-GB.js" libraries from date.js

Following command gives a not null result indicating its a valid date, but it isn't actually.

Date.parseExact('01/13/2013', 'dd/mm/yyyy')

Any idea what might be wrong here?


Solution

  • You should be using M or MM

    Date.parseExact('01/13/2013', 'd/M/yyyy')
    

    Lowercase m is 'minutes', and since a month wasn't specified in your format string, the library defaulted to use the current month.