How do I get Month and Date of JavaScript in 2 digit format?

("0" + this.getDate()).slice(-2)

for the date, and similar:

("0" + (this.getMonth() + 1)).slice(-2)

for the month.

Leave a Comment