var dateString = "20151208180700";var pattern = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;var formatedDate = dateString.replace(pattern, '$1-$2-$3 $4:$5:$6');alert(formatedDate);console.log(formatedDate);
本文共 258 字,大约阅读时间需要 1 分钟。
var dateString = "20151208180700";var pattern = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;var formatedDate = dateString.replace(pattern, '$1-$2-$3 $4:$5:$6');alert(formatedDate);console.log(formatedDate);
转载于:https://www.cnblogs.com/mchuang/p/5029930.html