Reputation: 2089
I would like to know how to parse date strings that could have different date format.
For now I do the following to parse my date strings:
var parseDate = d3.time.format("%Y-%m-%d %H:%M").parse;
How to specify multiple date format to my parseDate
function?
Upvotes: 1
Views: 808
Reputation: 2072
new Date('YOUR DATE STRING')
Also checkout moment.js,
You can use moment('YOUR DATE STRING')
moment
will try to interpret the String according to standard formats, if not it will fall back to Javascript's native Date()
constructor.
This should work for standard ISO format or a variety of commonly seen date formats. Obviously it is not magic and will not understand all possible permutations of YYYY MM and DD
Upvotes: 2