latex-ub/services/web/frontend/js/utils/dates.ts
2025-05-05 12:24:05 +00:00

13 lines
329 B
TypeScript

import moment from 'moment'
export function formatDate(date: moment.MomentInput, format?: string) {
if (!date) return 'N/A'
if (format == null) {
format = 'Do MMM YYYY, h:mm a'
}
return moment(date).format(format)
}
export function fromNowDate(date: moment.MomentInput | string) {
return moment(date).fromNow()
}