Get month in mm format in javascript

date, javascript

Solution

if (currentMonth < 10) { currentMonth = '0' + currentMonth; }

Problem

How do I retrieve the month from the current date in `mm` format? (i.e. "05") This is my current code: ``` var currentDate = new Date(); var currentMonth = currentDate.getMonth() + 1; ```

Original source

Related problems