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