When we call getMonth() and getDate() on date object, we will get the single digit number. For example :
getMonth()
getDate()
date
single digit number
For january, it displays 1, but I need to display it as 01. How to do that?
january
1
01
("0" + this.getDate()).slice(-2)
for the date, and similar:
("0" + (this.getMonth() + 1)).slice(-2)
for the month.
1.4m articles
1.4m replys
5 comments
56.9k users