MCPcopy Create free account
hub / github.com/evolify/dumpfun / formatTime

Function formatTime

common/utils/format.ts:26–46  ·  view source on GitHub ↗
(timestamp: string)

Source from the content-addressed store, hash-verified

24}
25
26export function formatTime(timestamp: string) {
27 const date = new Date(timestamp)
28 const now = new Date()
29 const diff = now.getTime() - date.getTime()
30 const seconds = Math.floor(diff / 1000)
31 const minutes = Math.floor(seconds / 60)
32 const hours = Math.floor(minutes / 60)
33 const days = Math.floor(hours / 24)
34 const months = Math.floor(days / 30)
35 if (months > 1) {
36 return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
37 } else if (days > 0) {
38 return `${days}d`
39 } else if (hours > 0) {
40 return `${hours}h`
41 } else if (minutes > 0) {
42 return `${minutes}m`
43 } else {
44 return `${seconds}s`
45 }
46}
47
48export function formatDate(date: string) {
49 const d = new Date(date)

Callers 3

ItemFunction · 0.90
DataTableFunction · 0.90
DetailFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected