Skip to content

Date functions

Functions related to dates and time

formatTime(time, maxLength, allowAffixes)

Format a time

Details
  • Parameters
    • time - Time in milliseconds (negative number represents time in the past)
      • Type: number
    • maxLength - The maximum amount of units, e.g.: 3 => years, months, days
      • Type: number | undefined
      • Default: 3
    • allowAffixes - Allow "... ago" or "in ..."
      • Type: boolean
  • Returns
    • Type: string

formatRelativeTime(date, maxLength, allowAffixes)

Format a time relative to now

Details
  • Parameters
    • date
      • Type: Date
    • maxLength - The maximum amount of units, e.g.: 3 => years, months, days
      • Type: number | undefined
      • Default: 3
    • allowAffixes - Allow "... ago" or "in ..."
      • Type: boolean
  • Returns
    • Type: string

Built by Prozilla