mirror of
https://github.com/vercel-labs/natural-language-postgres.git
synced 2026-11-04 08:10:38 +00:00
9 lines
224 B
TypeScript
9 lines
224 B
TypeScript
import ms from 'ms'
|
|
|
|
export const timeAgo = (timestamp: Date, timeOnly?: boolean): string => {
|
|
if (!timestamp) return 'never'
|
|
return `${ms(Date.now() - new Date(timestamp).getTime())}${
|
|
timeOnly ? '' : ' ago'
|
|
}`
|
|
}
|