我在react.js文件中有一个方法,它将日期保存在下面的bigint字段中
getTodaysDate(){ let formatTwoDigits =(digit)=> (“0”+数字).slice(-2); var tempDate = new Date();…
你可以使用替换。
^(\d{4})(\d{2})(\d{2}).* | | | |_____ Anything except new line | | | | | |_________ Day ( group 3 `$3`) | | | |_________________ Month ( group 2 `$2`) | |_________________________ year ( group 1 `$1`)
let str = `20190313133112` let op = str.replace(/^(\d{4})(\d{2})(\d{2}).*/,"$2/$3/$1") console.log(op)