``
效果图
formatTime(time: number) {
if (!time || time < 0) return '';
const days = moment().diff(moment(time).startOf('day'), 'days');
if (days === 0) return moment(time).format('HH:mm');
if (days === 1) return `昨天 ${moment(time).format('HH:mm')}`;
return moment(time).format('YYYY-MM-DD HH:mm:ss');
}
formatTime(time: number) {
const days = moment().diff(moment(time).startOf('day'), 'days');
if (days === 0) return moment(time).format('HH:mm');
if (days === 1) return `昨天 ${moment(time).format('HH:mm')}`;
return moment(time).format('YYYY-MM-DD HH:mm:ss');
},
getTimeInfo() {
const now = new Date().getHours();
if (now < 6) return '晚上好';
if (now < 7) return '早上好';
if (now < 11) return '上午好';
if (now < 13) return '中午好';
if (now < 18) return '下午好';
return '晚上好';
}