Num-to-string (padded)

function NumToStrPad(num, length: number): string

This functions takes a number num and returns a string representation of that number padded with zeroes to ensure that the resulting string is not shorter than length. Useful, for example, when you want a 2-digit representation of month and day number in a date.


  var date = new Date();
  var month = date.getMonth() + 1;
  monthStr = NumToStrPad(month, 2);
  // Ex: in May, monthStr will contain the string "05"