0
I’m handling dates from a form, and a value such as 2026-03-08 can show up as the previous calendar day when I display it in my local timezone. I expected a date without a time to stay on the same date.
Here’s the kind of parsing I’m doing:
const dateOnly = "2026-03-08"; // A date string with no time or timezone
const parsed = new Date(dateOnly); // Parse the string into a Date object
console.log(parsed.toString()); // Display the date using the local timezone
Is this a difference between a calendar date and a timestamp, or am I making an assumption about how JavaScript parses ISO date strings? I’d be interested in how others represent date-only values when they need to avoid timezone shifts.