How to get minutes ago in JavaScript

Datetime
By Jad Joubran · 
Last updated Feb 27, 2024
const formatter = new Intl.RelativeTimeFormat("en", {
  // Change to "short" for min. (instead of minutes)
  style: "long"
});

// -5 can be the difference between 2 date objects
formatter.format(-5, "minutes");
5 minutes ago