<body>
<p id="demo">Click the button to display the date and time as a string, using the ISO standard.</p>
<button οnclick="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>
http://blog.csdn.net/hj7jay/article/details/51433745
对于后台传过来的json数据是带T时间格式的坑处理的一些做法总结
new Date(data[j].addtime).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
仅针对这个问题来说,不需要那么大量的代码即可完成
方案1(适用于中国标准时间):
方案2(只用于题目中所述的格式转换):
方案3(最准确但最麻烦,不推荐):