function getNowTime(date = new Date()) {
var format = num => num < 10 ? '0' + num : num;
let d = new Date();
let y = date.getFullYear();
let m = format(date.getMonth() + 1)
let day = format(date.getDate());
let h = format(date.getHours());
let min = format(date.getMinutes());
let s = format(date.getSeconds())
let time = `${y}-${m}-${day} ${h}:${min}:${s}`
return time
}
function diff(d1, d2) {
return ((d1.getTime() - d2.getTime()) / 1000).toFixed(2)
}
fetch("https://lab.whuh.com/device-appointment-server-api/api/v1/order/record", {
"body": "{\"orderTime\":\"08:00-09:30\",\"orderDate\":\"2022-09-06\",\"equipmentId\":\"7a20fea6d6e22799ad1f0251424279eb\",\"equipmentName\":\"激光共聚焦\",\"phone\":\"\"}",
"method": "POST",
}).then(res => res.json()).then(data => {
let now = new Date()
alert(`
当前浏览器时间A:${getNowTime(now)};
当前系统时间B:${data.date};
A - B = ${diff(now, new Date(data.date))} 秒
`)
})
console