mazey
    Preparing search index...

    Function formatDistanceToNow

    • Format the absolute distance from a date to now in concise English words.

      Usage:

      import { formatDistanceToNow } from "mazey";

      const ret = formatDistanceToNow(new Date(Date.now() - 60 * 60 * 1000));
      console.log(ret);

      Output:

      about 1 hour
      

      Parameters

      • date: MazeyDate

        A Date, millisecond timestamp, or string accepted by isValidDate.

      Returns string

      The absolute approximate distance phrase, or an empty string for invalid input.

      Past and future dates use the same wording without ago or in. Months and years use fixed approximate durations of 30 and 365 days.