How to display 2 digits numbers of time left [countdown jquery] ?
My code will show
66days7hours6minutes2seconds
but I want to display 2 digits number e.g.
66days07hours06minutes02seconds
how to do that ?
How to display 2 digits numbers of time left [countdown jquery] ?
My code will show
66days7hours6minutes2seconds
but I want to display 2 digits number e.g.
66days07hours06minutes02seconds
how to do that ?
You can append the leading zeroes, and then use substr to cut the string to the required length:
day = ("00" + day).substr(-2);
hour = ("00" + hour).substr(-2);
minute = ("00" + minute).substr(-2);
second = ("00" + second).substr(-2);
The -2 parameter means that you want to take the 2 characters from the end of the string.