programming-examples/js/Date/Write a JavaScript function to get minutes with leading zeros (00 to 59)..js
2019-11-15 12:59:38 +01:00

10 lines
276 B
JavaScript

function minutes_with_leading_zeros(dt)
{
return (dt.getMinutes() < 10 ? '0' : '') + dt.getMinutes();
}
dt = new Date();
console.log(minutes_with_leading_zeros(dt));
dt = new Date(1989, 10, 1);
console.log(minutes_with_leading_zeros(dt));