2022-02-17T16:00:00.000Z时间格式的转换

// 时间戳转格林威治时间2022-02-17T16:00:00.000Z

function formatDateT(dataTime) {
  var newDate = new Date(dataTime)
  return newDate.toISOString()
}

// 申请日期:2022-02-17T16:00:00.000Z转2022-02-18 00:00:00,type===1时,返回2022-02-18

function timeTrans(time, type){
  let date = new Date(new Date(time).getTime() + 8 * 3600 * 1000)
  date = date.toJSON();
  if (type===1){
    date = date.substring(0, 10)
  }
  else {
    date = date.substring(0, 19).replace('T', ' ')
  }
  return date
}

你可能感兴趣的:(前端)