Reputation: 608
I have a date in string format as
var addedDate = "2016-10-03T00:00:00.000Z";
How to check if this string
After doing some research I see that I can check using isValid method in Moment.js
moment(addedDate, formatToCheck).isValid();
how should look "formatToCheck" format
formatToCheck=???
Upvotes: 2
Views: 3053
Reputation: 1
var addedDate = "2016-10-03T00:00:00.000Z"; Then how to assign value for year month and day from he above string in json format like Year: value, month:value, day: value
Upvotes: 0
Reputation: 7496
You can do something like this
moment('2016-10-03T00:00:00.000Z', 'YYYY-MM-DD').isValid();
To check the full format,i guess you can do something like this
moment('2016-10-03T00:00:00.000Z', 'YYYY-MM-DD HH:mm:ms').isValid();
Upvotes: 2