Skip to content

Instantly share code, notes, and snippets.

@monkianer
Last active July 2, 2017 05:18
Show Gist options
  • Save monkianer/a912bcdf146ec905307b578b30446e78 to your computer and use it in GitHub Desktop.
Save monkianer/a912bcdf146ec905307b578b30446e78 to your computer and use it in GitHub Desktop.
Add "0" to a number and change it to string
function AddZeroDigitsBefore(d, digits){
var nStr = d + '';
var digits = digits || 0;
while(nStr.length < digits){
nStr = '0' + nStr;
}
return nStr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment