20200101235959格式的时间 转换成为 YYYY:MM:DD HH:mm:ss
利用正则进行转换:
const date = '20190107142208';
const formatDate = date.replace(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/, '$1-$2-$3 $4:$5:$6');
console.log(formatDate); // 2019-01-07 14:22:08
利用正则进行转换:
const date = '20190107142208';
const formatDate = date.replace(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/, '$1-$2-$3 $4:$5:$6');
console.log(formatDate); // 2019-01-07 14:22:08