1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Vue.filter('relativeTime', (date) => { const diff = dayjs().diff(date, 'day') if (diff === 0) { return dayjs(date).format('HH:mm') } else if (diff === 1) { return '昨天' } else if (diff < 7) { return dayjs(date).format('dddd') } else if (diff < 365) { return dayjs(date).format('M月DD日') } else { return dayjs(date).format('YYYY年M月DD日') } })
|