Adding extra zeros in front of a number using jQuery?

后端 未结 14 1185
粉色の甜心
粉色の甜心 2020-11-30 02:45

I have file that are uploaded which are formatted like so

MR 1

MR 2

MR 100

MR 200

MR 300

14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 03:13

    By adding 100 to the number, then run a substring function from index 1 to the last position in right.

    var dt = new Date();
    var month = (100 + dt.getMonth()+1).toString().substr(1, 2);
    var day = (100 + dt.getDate()).toString().substr(1, 2);
    
    console.log(month,day);
    

    you will got this result from the date of 2020-11-3

    11,03
    

    I hope the answer is useful

提交回复
热议问题