示例如下,可运行哦,望采纳:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript ISO Dates</h2>
<p id="demo"></p>
<script>
const d = "20230113105621".replace(
/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/,
"$1/$2/$3 $4:$5:$6");
document.getElementById("demo").innerHTML = d;
</script>
</body>
</html>
先判断位数是否等于14,再利用字符串截取拼接