Date.js Parseexact() Not Parsing 4 Digit Years When Passed In As An Array
Am I missing something with Date.parseExact() in date.js? According to the api documentation, I should be able to do this: Date.parseExact('10/15/2004', ['M/d/yyyy', 'MMMM d, yyyy
Solution 1:
It appears date.js is attempting to parse the four-digit year as a two-digit year, failing, and returning null on failure.
To prevent this, switch your masks around so it tries the four-digit masks first:
$(function () {
$('#FCSaleDate').change(function (e) {
var d = Date.parseExact($(this).val(),["MMddyyyy","MMddyy","M/d/yyyy","M/d/yy"]);
alert(d.toString("MM/dd/yyyy"));
});
});
http://jsfiddle.net/mblase75/ttEqh/1/
Post a Comment for "Date.js Parseexact() Not Parsing 4 Digit Years When Passed In As An Array"