Reputation: 130
Why does the following output "false"?
var date = moment(["2014", "08", "31"]);
alert( date.isValid() );
I'm using this version of the library
Upvotes: 1
Views: 102
Reputation: 17876
Months are 0 relative. So you're trying to get August 31st, 2014. In reality though, you're getting September 31st, 2014. Which is not valid because September only has 30 days.
Try this...
var date = moment(["2014", "07", "31"]);
alert( date.isValid() );
Upvotes: 2