JS - 2020-01-01T00:00:00.000000Z 日期格式转换


 

日期格式转换

2020-06-27T14:20:27.000000Z 时间格式转换成 2020-06-27 14:20:27
function rTime(date) { var json_date = new Date(date).toJSON(); return new Date(new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '') } let date = rTime('2020-06-27T14:20:27.000000Z'); console.log(date) // 2020-06-27 14:20:27

toJSON() 方法可以将 Date 对象转换为字符串,并格式化为 JSON 数据格式。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM