How do I format 7 as '07' in string in JavaScript?
<p>I have JavaScript day, month and year. I need my day to be in 2 digits, my months also to be in 2 digits and year in 4 digits.</p>

<p><strong>Eg.</strong> If month is <code>7</code> it should give me string as <code>'07'</code>. If it is <code>12</code> then it should return <code>'12'</code>.</p>

<p>I google for it but I only found <code>toFixed</code> and <code>toPrecision</code>, both of which have different functions. How do I format it?</p>
