IR Framework

Number.toPaddedString Method

Pads the left of a number with zeros to format the number to be a specific width.
object.toPaddedString (NumDigits)

Arguments

object
Required. Always the name of a Number object.


NumDigits
Required. The minimum number of characters in the output number.



Return Value

The Number.toPaddedString method returns the following values:
If Number.toPaddedString returns
NumDigits is smaller than the length of the string resulting from rounding the number to the nearest integer (Math.round(object).toString().length) A string containing the original number rounded to the nearest integer.
NumDigits is larger than the length of the string resulting from rounding the number to the nearest integer A string containing the original number rounded to the nearest integer with enough zeros to make the string NumDigits characters wide.
NumDigits is not a positive integer "Input Error"

Remarks

The following example illustrates the use of the Number.toPaddedString method.

var d = new Date();
var sDate = new String();

sDate = (d.getMonth() + 1).toPaddedString(2);
sDate += "/" + d.getDate().toPaddedString(2);
sDate += "/" + d.getFullYear();

Alert(sDate);
//	displays "" in an Alert box


Requirements

String.times()