How to display 2 digits of remaining time number [jquery countdown]?
2 answers
You can add leading zeros and then use substr
to cut the string to the length you want:
day = ("00" + day).substr(-2);
hour = ("00" + hour).substr(-2);
minute = ("00" + minute).substr(-2);
second = ("00" + second).substr(-2);
The parameter -2
means that you want to take 2 characters from the end of the string.
+5
source to share