I have a string with values separated by commas, and I'm trying to create a Date object from it. It seems like this is not doable -- can someone verify this and provide a solution if possible?
This code snippet doesn't work :
let dateString='2017,3,22,0';
let dateFromString = new Date(dateString);
However, this code works fine (when passing individual numbers) :
let dateFromString = new Date(2017,3,22,0);
And this code also works :
let dateString = '2008/05/10 12:08:20';
let dateFromString = new Date(dateString);
The objective is to generate a Date object from a consistent string format. Is there a way to achieve this?
Can I generate a Date object from a standard string that uses only one type of separator (comma, colon, slash, etc.)?