var date = \"2012-01-18T16:03\";
var date = new Date(date);
console.log(date.getMinutes());
console.log(date.getMinutes().length)
This returns 3.
I would like to provide a more neat solution to the problem if I may.The accepted answer is very good. But I would have done it like this.
Date.prototype.getFullMinutes = function () {
if (this.getMinutes() < 10) {
return '0' + this.getMinutes();
}
return this.getMinutes();
};
Now if you want to use this.
console.log(date.getFullMinutes());