I have this value:
this.value.day
It returns a number from 1 to 31.
However, I'd like to insert a 0 if it's less than 10, how can I do that?
I have this value:
this.value.day
It returns a number from 1 to 31.
However, I'd like to insert a 0 if it's less than 10, how can I do that?
One liner and cross browser compatible
newValue = ('0' + this.value.day.toString()).slice(-2);
Well, this is not an elegant solution, but it gets the job done.
if (this.value.day < 10) {
this.dayRender = "0" + this.value.day;
} else {
this.dayRender = this.value.day;
}