prepend zero to number

for use in a time display, I need to prepend a 0(zero) to the minutes less than ten.

Here is a function that will do that:

function pad(n) { 
if (n < 10) 
return "0" + n; 
return n; }

Leave a Reply