sanyekui

 

日期格式转换

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 数据格式。

 

分类:

技术点:

相关文章:

  • 2021-11-27
  • 2022-01-01
  • 2022-01-01
  • 2022-01-07
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-11-27
相关资源
相似解决方案