patient-mini/pages/chat/index.wxs
码农搬砖工 9018a4f868 xxx
2025-04-23 18:23:41 +08:00

29 lines
810 B
XML

/** 将数字补足2位 */
function formatNum(num) {
return num < 10 ? '0' + num : num;
}
/** */
function formatTime(time) {
var date = getDate(time);
var now = getDate();
var Y = date.getFullYear(),
M = date.getMonth() + 1,
D = date.getDate(),
h = date.getHours(),
m = date.getMinutes();
var Y0 = now.getFullYear(),
M0 = now.getMonth() + 1,
D0 = now.getDate();
if (Y === Y0) {
if (M === M0 && D === D0) return ' ' + formatNum(h) + ':' + formatNum(m);
if (M === M0 && D === D0 - 1) return ' ' + formatNum(h) + ':' + formatNum(m);
return M + '' + D + ' ' + formatNum(h) + ':' + formatNum(m);
}
return Y + '' + M + '' + D + ' ' + formatNum(h) + ':' + formatNum(m);
}
module.exports = {
formatTime: formatTime,
};