var date = \"2012-01-18T16:03\"; var date = new Date(date); console.log(date.getMinutes()); console.log(date.getMinutes().length)
This returns 3.
I suggest:
var minutes = data.getMinutes(); minutes = minutes > 9 ? minutes : '0' + minutes;
it is one function call fewer. It is always good to think about performance. It is short as well;