我们可以利用正则表达式对带有T\G\Z等字母的时间进行格式化,案例代码如下:
<body>
<p id="demo">Click the button to display the date and time as a string, using the ISO standard.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var dateee = new Date("2017-07-09T09:46:49.667").toJSON();
var date = new Date(+new Date(dateee)+8*3600*1000).toISOString().replace(/T/g,' ').replace(/\.[\d]{3}Z/,'')
alert(date);
}
</script>