Am I missing something with Date.parseExact () in date.js? According to the api documentation, I have to do this:
Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]);
That is, I should be able to pass an array of strings containing "... the expected format {String} or an array of expected formats {Array} date strings." However, when I do this:
var d = Date.parseExact($(this).val(), ["MMddyy", "Mddyyyy", "MM/dd/yy","MM/dd/yyyy"])
I return zeros for dates containing 4-digit years (that is, corresponding to the formats MMddyyyy and MM / dd / yyyy). Am I missing something or is it an error in Date.js?
Here is the complete code block for context:
$(function () { $('#FCSaleDate').change(function (e) { var d = Date.parseExact($(this).val(), ["MMddyy", "MMddyyyy", "MM/dd/yy","MM/dd/yyyy"]) alert(d.toString("MM/dd/yyyy")); }); });
source share