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,
options?: FormatRelativeOptions,
): string;§
formatRelative<DateType extends Date>(date: DateType | number | string, baseDate: DateType | number | string, options?: FormatRelativeOptions): string
[src]§Parameters
§
options?: FormatRelativeOptions optional
[src]- An object with options