How to replace a string at a particular position

后端 未结 6 1535
深忆病人
深忆病人 2020-12-10 12:30

Is there a way to replace a portion of a String at a given position in java script. For instance I want to replace 00 in the hours column with 12 i

6条回答
  •  粉色の甜心
    2020-12-10 13:04

    Another creative idea could be converting into Array, splice and convert it back to String.

    let str = "Mar 16, 2010 00:00 AM";
    let arr = str.split("");
    arr.splice(13,2,"1","2");
    str = arr.join("");
    

提交回复
热议问题