Get double digits string of a number

var toDoubleDigits = function(num) { num += ""; if (num.length === 1) { num = "0" + num; } return num; };
use this when you want to make "1" to "01".

e.g.

from "2011/1/1" to "2011/01/01"

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.