JavaScript/jQuery - two format date
===

I have function:


    sample(date){
      //operations, for example add one week (7 days) 
    
      return date;
    }

    var one = new Date('2012-07-16');
    var two = new Date('07/16/2012');

   var new = sample(one); // or sample(two)


    var day = new.getDate();
    var month = new.getMonth();
    var year = new.gerYear();
    
    alert(day + month + year);

and now i would like show this date, but how can i check format this date? 
For example:

    alert(sample(one));

should show me date with format **2012-07-23**
and if 

    alert(sample(one));

should show me **07/23/2012**

but how can i check format current date? is this possible?