UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

12 lines 354 B
import dayjs from 'dayjs'; export var formatTime = function formatTime(time) { var now = dayjs(); var target = dayjs(time); if (target.isSame(now, 'day')) { return target.format('HH:mm:ss'); } else if (target.isSame(now, 'year')) { return target.format('MM-DD HH:mm:ss'); } else { return target.format('YYYY-MM-DD HH:mm:ss'); } };