I'm having a problem with substr() in JavaScript.
Please look at the code below.
The following works as expected. y = 2017
var add_date = "20170505";
var y = add_date.substr(0, 4);
alert(y);
But... the following doesn't work. It should return '05' but instead it returns 0505. m = 0505
var add_date = "20170505";
var m = add_date.substr(4, 6);
alert(m);
Could someone explain me what's wrong?
Thanks,
Nathan