使用不同的浏览器时,发现有的时候日期获取后转换计算会报错,搜索了解决方案,原来是对-不识别,要转换成/才可以,即要加上一步转换:日期str.replace(new RegExp(/-/gm) ,"/");
特此记录一下小tips~~
<script>
var nowTime = "2019-03-12 10:08:44";
nowdate=nowTime.replace(new RegExp(/-/gm) ,"/");
alert(nowTime);
alert(nowdate);
</script>
<html>
aaa
</html>