const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
console.log(rtf.format(-1, "day"));
console.log(rtf.format(2, "week"));
yesterday and in 2 weeksWith numeric: "auto", the formatter uses words like "yesterday", "today" and "tomorrow" when the language has them. Otherwise it writes "in 2 weeks".
"1 day ago" is the tempting wrong answer. That is the output with the default, numeric: "always". Note that RelativeTimeFormat only formats. You still calculate the difference and choose the unit yourself.