Original code
const start = new Date();
console.log(start);
Result
2023-12-14T20:11:12.388Z
My time zone is America/New_York, 5 hours behind UTC.
Question
How should I convert a new Date object in the format of?
2023-12-14T15:11:12-05:00
I've been trying things like this but no luck yet,
const start = new Date();
const dateFormat = new Intl.DateTimeFormat("en-US", {
timeZone: "America/New_York",
dateStyle: "short",
timeStyle: "long"
});
console.log(dateFormat.format(start));
Either native JS, or date-fns is fine.
Seems
formatISOfrom date-fns works:The output of last run is