var old_day = "5";var new_day; if(old_day.length == 1) { new_day = "0" + old_day; }
is this what you mean here is an alternative if your old_day is an integer value var old_day = 5;var new_day; if(String(old_day).length == 1) { new_day = "0" + old_day; } On Wed, Oct 21, 2009 at 8:48 AM, petermdenton <petermden...@gmail.com>wrote: > > Hello, > I am wondering if someone can share a good clean way of converting a > single digit day to a double digit day. For example, I have date1 = 5 > and I want that to be 05. > > Thanks in advance > Peter >