function dateTimeFormat(timestamp, locale, str, ...opts) { const d = new Date(timestamp); return str.replace(/{(\d+)}/g, function(match, number) { return typeof opts[number] != 'undefined' ? new Intl.DateTimeFormat(locale, opts[number]).format(d) : match; }); } console.log(dateTimeFormat("2021-11-19T19:19:36.598071-06:00", "en", "{0} at {1}!", {dateStyle:"short"}, {timeStyle:"long"})) // => "11/19/21 at 7:19:36 PM CST!"