title: javascript date to string
body: <p>Here is what I need to do. </p>
  
  <p>Get Date, convert to string and pass it over to a third party utility. 
  The response from the library will have date in string format as I passed it. So, I need to convert the date to string like 20110506105524 (YYYYMMDDHHMMSS)</p>
  
  <pre><code>function printDate() {
      var temp = new Date();
      var dateStr = temp.getFullYear().toString() + 
                    temp.getMonth().toString() + 
                    temp.getDate().toString() +
                    temp.getHours().toString() + 
                    temp.getMinutes().toString() + 
                    temp.getSeconds().toString();
  
      debug (dateStr );
  }
  </code></pre>
  
  <p>The problem with above is that for months 1-9, it prints one digit. How can I change it to print exactly 2 digits for month, date ...</p>