javascript pad number with leading zeros
function padLeadingZeros(num, size) {
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
}
padLeadingZeros(57, 3);// "057"
padLeadingZeros(57, 4); //"0057"
javascript pad number with leading zeros
function padLeadingZeros(num, size) {
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
}
padLeadingZeros(57, 3);// "057"
padLeadingZeros(57, 4); //"0057"
js number add zero before
('0' + 11).slice(-2) // '11'
('0' + 4).slice(-2) // '04'
Adding "0" if clock have one digit
let str = "34"
str = str.padStart(4, "0") // results in "0034"
console.log(str)
For Clock Example :
var now = new Date();
var year= now.getFullYear();
var month= (now.getMonth()+1).toString().padStart(2, "0");
var day= now.getDate().toString().padStart(2, "0");
var hour = now.getHours().toString().padStart(2, "0");
var minute = now.getMinutes().toString().padStart(2, "0");
document.getElementById("date").innerHTML =`${day}-${month}-${year}-${hour}:${minute}`;
<div id="date"></div>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us