Nomor JS Tambahkan nol sebelumnya
('0' + 11).slice(-2) // '11'
('0' + 4).slice(-2) // '04'
GutoTrosla
('0' + 11).slice(-2) // '11'
('0' + 4).slice(-2) // '04'
function checkTime(i) {
if (i<10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
var str = "5";
alert(str.lpad("0", 4)); //result "0005"
var str = "10"; // note this is string type
alert(str.lpad("0", 4)); //result "0010"