You choose October 13 in a form, save the value, then the calendar displays the 12th. The picker does not necessarily have a bug. The issue often appears when a date without a time passes through a Date object, then through a UTC conversion with toISOString().
For a birth date, a deadline, or a booking day, the right fix is not to automatically add a day. First decide what the data represents: a calendar day, or a specific instant. They are not stored in the same way.
Why toISOString() can show the previous day
toISOString() always returns the instant in UTC. The final Z indicates that. If you create a date at midnight in a time zone ahead of UTC, that instant is still on the previous day in UTC. Taking the first ten characters of the string keeps the UTC day, not the local day.
const localMidnight = new Date(2026, 9, 13);
console.log(localMidnight.toISOString());
console.log(localMidnight.toISOString().slice(0, 10));
In the Europe/Paris time zone, this example produces 2026-10-12T22:00:00.000Z, then 2026-10-12. The month is 9 because the numeric constructor counts January as zero. This result depends on the environment’s time zone: in UTC, the day does not change. The code therefore does not prove that JavaScript made a mistake; it reveals a conversion your domain data did not require.
For a date input, keep the YYYY-MM-DD value
An HTML type="date" field exposes its value as YYYY-MM-DD, even if the interface displays a localized date. That string contains neither a time nor a time zone. To retain the selected day, read value and send that string unchanged.
const input = document.querySelector('input[type="date"]');
const selectedDate = input.value;
if (selectedDate !== '') {
const payload = { bookingDate: selectedDate };
console.log(JSON.stringify(payload));
}
With October 13, 2026 selected, bookingDate is 2026-10-13. When loading the form, assign that same string to input.value. Do not insert new Date() when no operation on an instant is needed. An empty value is still a case to handle; do not turn it into a date arbitrarily.
This approach assumes that your API expects a civil date. On the server, validate both the format and that the day actually exists, then use a suitable storage type, such as an SQL DATE column. A regular expression that checks only the shape does not by itself reject February 31. Browser validation does not replace server validation.
The second trap: new Date('2026-10-13')
An ISO string limited to a date, with no time, is interpreted as midnight UTC. That differs from the numeric constructor new Date(2026, 9, 13), which uses the local time zone. In a time zone behind UTC, reading that date with local accessors can therefore display the 12th.
const parsed = new Date('2026-10-13');
console.log(parsed.toISOString());
console.log(parsed.getDate());
console.log(parsed.getUTCDate());
In America/Los_Angeles, the results are 2026-10-13T00:00:00.000Z, 12, and 13. In Paris, both day numbers are 13 in this example. Mixing a UTC construction with a local read explains why a form works for one developer but fails for another.
The valueAsDate property of a date field requires the same care: its date represents midnight UTC. If you use it, read the UTC components. To simply send the selected day, value is more direct.
Populate the field with today’s local date
The shortcut new Date().toISOString().slice(0, 10) returns the current day in UTC. If your form needs the user’s local day, build the string from local accessors.
function localDateString(date = new Date()) {
if (Number.isNaN(date.getTime())) {
throw new RangeError('Invalid date');
}
const year = String(date.getFullYear()).padStart(4, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}
const input = document.querySelector('input[type="date"]');
input.value = localDateString();
This helper targets ordinary four-digit years. It uses the time zone of the machine running the code. In a browser, that is normally the user’s time zone; on a Node.js server, it is the server’s time zone. For a booking tied to an establishment’s time zone, explicitly apply that business time zone rather than assuming the browser’s one is suitable.
When to keep toISOString()
For the time a message is sent, a log entry, or an event timestamped to the second, a UTC instant is useful exchange data. In that case, toISOString() remains appropriate: store the instant, then display it in the intended time zone. A birth date, by contrast, does not need to become midnight UTC.
- Calendar day: keep the
YYYY-MM-DDstring, with no implicit time-zone conversion. - Specific instant: keep a timestamp or an ISO string with an explicit offset, then localize the display.
- Appointment at a location: define the business time zone and the API contract before converting.
Avoid patches such as adding 24 hours or subtracting a fixed offset. They hide the wrong model and can fail around daylight-saving changes. A civil date is not a 24-hour duration to move around.
Verify the fix in several time zones
To reproduce the issue with Node.js on Linux or macOS, run the following commands. On Windows, set TZ in your shell before running Node; the syntax below is for POSIX shells.
TZ=Europe/Paris node -e 'console.log(new Date(2026, 9, 13).toISOString())'
TZ=America/Los_Angeles node -e 'console.log(new Date("2026-10-13").getDate())'
TZ=UTC node -e 'console.log(new Date(2026, 9, 13).toISOString())'
You should respectively get 2026-10-12T22:00:00.000Z, 12, and 2026-10-13T00:00:00.000Z. Then test the entry, the JSON sent, the value actually stored, and the field reload. If the string remains 2026-10-13 but the screen displays the 12th, look for the conversion in the display layer rather than in the picker.
To review the language fundamentals, see our complete JavaScript programming guide for beginners. The decisive point here is simple: do not turn a selected day into an instant if your application does not need a time.
Technical sources
- MDN: Date.prototype.toISOString(), for UTC output and the Z suffix.
- MDN: the HTML date input, for the normalized value without a time.
- MDN: the Date() constructor, for local components.
- MDN: valueAsDate, for UTC reading of a date field.

