Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

formatRelative

import { formatRelative } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// Represent the date of 6 days ago in words relative to the given base date. In this example, today is Wednesday
const result = formatRelative(subDays(new Date(), 6), new Date())
//=> "last Thursday at 12:45 AM"
function formatRelative<DateType extends Date>(
date: DateType | number | string,
baseDate: DateType | number | string,
): string;
§
formatRelative<DateType extends Date>(date: DateType | number | string, baseDate: DateType | number | string, options?: FormatRelativeOptions): string
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The date to format
§
baseDate: DateType | number | string
[src]
  • The date to compare with
§
options?: FormatRelativeOptions optional
[src]
  • An object with options

§Return Type

§
string
[src]

The date in words