var date = \"2012-01-18T16:03\"; var date = new Date(date); console.log(date.getMinutes()); console.log(date.getMinutes().length)
This returns 3.
Another short way is to fill the minutes with a leading zero using:
String(date.getMinutes()).padStart(2, "0");
Meaning: Make the string two chars long, if a char is missing then set 0 at this position.
0
See docs at str.padStart(targetLength, padString)