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);
时间: 2024-10-12 13:17:24
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);