This is a noob question:
How to parse a date in format \"YYYYmmdd\" without external libraries ? If the input string is not in this format I would like
\"YYYYmmdd\"
Example using only the digits in the string:
function toDate(str) { var m = str.split(/\D/); return new Date(+m[0], +m[1] - 1, +m[2], +m[3], +m[4], +m[5]); } console.log(toDate("2020-08-23 23:34:45"));