Home / Function/ formatTimestamp() — supabase Function Reference

formatTimestamp() — supabase Function Reference

Architecture documentation for the formatTimestamp() function in Reports.utils.tsx from the supabase codebase.

Entity Profile

Relationship Graph

Source Code

apps/studio/components/interfaces/Reports/Reports.utils.tsx lines 58–81

export const formatTimestamp = (
  timestamp: number | string,
  { returnUtc = false, format = 'MMM D, h:mma' }: { returnUtc?: boolean; format?: string } = {}
) => {
  try {
    const isSeconds = String(timestamp).length === 10
    const isMicroseconds = String(timestamp).length === 16

    const timestampInMs = isSeconds
      ? Number(timestamp) * 1000
      : isMicroseconds
        ? Number(timestamp) / 1000
        : Number(timestamp)

    if (returnUtc) {
      return dayjs.utc(timestampInMs).format(format)
    } else {
      return dayjs(timestampInMs).format(format)
    }
  } catch (error) {
    console.error(error)
    return 'Invalid Date'
  }
}

Subdomains

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free