JavaScript new Date() off by one day or nine hours: date-only strings parsed as UTC and the toISOString trap
new Date("2026-11-26") lands at 9:00 in Japan and on the previous day in the US. toISOString().slice(0, 10) turns the date you picked into the day before. getMonth() returns 10 in November. This article traces why JavaScript Date shifts dates, using the ECMAScript string-parsing rules and actual results from Node.js and Chromium, and shows safe ways to handle date-only values.
You pick “2026-11-26” in a date field, save it, and the database ends up holding “2026-11-25”. Or you build a deadline with new Date("2026-11-26"), show it on screen, and a “9:00” comes along with it. Anyone who works with JavaScript’s Date runs into one of these one-day or nine-hour shifts sooner or later.
The causes boil down to three things: date-only strings are read as UTC, toISOString() writes in UTC, and months are counted from 0. None of these are bugs. They are the specified behavior, so once you know the rules you can both reproduce and avoid them.
The results in this article were checked with Node.js 22.23.5 and Chromium 158. I switched time zones with the TZ environment variable (Node.js) and Playwright’s timezoneId (Chromium). The baseline is Japan time (Asia/Tokyo, UTC+9), and New York (America/New_York, UTC−5 in November) serves as the example of a zone behind UTC.
Note for readers outside Japan: The examples below assume the code runs in Japan (UTC+9) or New York (UTC−5). The “nine hours” in the title is Japan’s offset from UTC. If your machine is set to another time zone, you will see a shift equal to your own UTC offset instead — for example 1 hour in Central Europe in winter, 0 in London in winter, or −8 hours on the US West Coast. To reproduce the exact outputs shown here, run the commands with
TZ=Asia/Tokyoas described at the end of the article.
A Date only holds an instant in time
First, the premise: a Date object holds a single number, the count of milliseconds since 00:00 UTC on January 1, 1970. It carries no time zone information and no marker that says “this is just a date.”
getDate(), getHours() and toString() reinterpret that number in the time zone of the runtime environment and display the result. That is why the same Date can give a different date on a PC in Japan and on a server in the US. Most date-shifting problems happen when you put a “date” — something that has nothing to do with time zone offsets — into a Date, which can only hold an instant.
Cause 1: Date-only strings are read as midnight UTC
The only difference between the following two lines is whether T00:00 is attached.
new Date("2026-11-26"); // date only
new Date("2026-11-26T00:00"); // date and time
Yet they produce different times. Run in Japan time, you get:
new Date("2026-11-26") → Thu Nov 26 2026 09:00:00 GMT+0900
new Date("2026-11-26T00:00") → Thu Nov 26 2026 00:00:00 GMT+0900
ECMAScript, the language specification for JavaScript, defines what happens when a string in the format Date accepts (the Date Time String Format) has no UTC offset (Z or +09:00): date-only forms are interpreted as UTC, while date-time forms are interpreted as local time.
So "2026-11-26" becomes “00:00 UTC on November 26,” which is 9:00 in Japan time. In Japan the date itself doesn’t change, so it’s easy to miss, but in regions behind UTC it becomes the previous day. Here is the same code running in New York:
new Date("2026-11-26") → Wed Nov 25 2026 19:00:00 GMT-0500
new Date("2026-11-26").getDate() → 25
Even a service built for Japanese users will expose this difference once it’s used from overseas or by employees at an overseas office.
valueAsDate on input type=“date” is the same
HTML date fields behave the same way. When you choose “2026-11-26” in an <input type="date">, value is the string "2026-11-26", but valueAsDate returns a Date representing midnight UTC. Checking in Chromium, it became the previous day in the New York time zone.
// Asia/Tokyo
input.value → "2026-11-26"
input.valueAsDate → Thu Nov 26 2026 09:00:00 GMT+0900
// America/New_York
input.valueAsDate → Wed Nov 25 2026 19:00:00 GMT-0500
input.valueAsDate.getDate() → 25
If you’re going to save or compare a date field’s value as is, using the value string rather than valueAsDate is the safer choice.
Slash- and space-separated strings are outside the spec
"2026/11/26" (the slash-separated style common in Japan) and "2026-11-26 00:00" both came out as midnight local time in Node.js and Chromium. But these are not formats defined by ECMAScript; their interpretation is left to each browser. Even if the result happens to be what you expected, there’s room for them to become Invalid Date or shift in time on a different environment. If you pass dates as strings, stick to YYYY-MM-DD or YYYY-MM-DDTHH:mm.
Cause 2: toISOString() writes in UTC
Here’s another classic piece of code that shifts the date back by a day.
const d = new Date(2026, 10, 26); // 00:00 on Nov 26, Japan time
const ymd = d.toISOString().slice(0, 10); // meant to extract "YYYY-MM-DD"
Run in Japan time, ymd becomes "2026-11-25".
d.toISOString() → "2026-11-25T15:00:00.000Z"
toISOString() always writes in UTC. The trailing Z means “this is a UTC time.” Midnight on November 26 in Japan is 15:00 on November 25 in UTC, so cutting off the first 10 characters gives you the previous day. Every time from 0:00 to 8:59 in Japan time falls on the previous day in UTC.
This shift only happens in regions ahead of UTC. Run the same code in New York and you get "2026-11-26", because it’s 5:00 on the 26th in UTC. That’s why toISOString().slice(0, 10) shows up so often in American sample code yet causes trouble in Japan.
Combined with Cause 1, the shifts can cancel out. new Date("2026-11-26").toISOString() reads in UTC and writes in UTC, so it gives "2026-11-26T00:00:00.000Z" wherever you run it. This combination is why things can work fine in tests and break only when a date built with new Date(2026, 10, 26) goes through.
Cause 3: Months count from 0
When you construct a date as new Date(year, month, day) or pull out the month with getMonth(), months start at 0. January is 0 and December is 11.
new Date(2026, 11, 26) → Sat Dec 26 2026 // 11 is December
new Date(2026, 10, 26).getMonth() → 10 // November, yet 10
On top of that, out-of-range values don’t throw an error; they roll over into a different date.
new Date(2026, 12, 1) → Fri Jan 01 2027 // month 13 → January next year
new Date(2026, 1, 30) → Mon Mar 02 2026 // Feb 30 → Mar 2
This rollover also shows up when you calculate “one month later.” Calling setMonth(getMonth() + 1) on January 31 rolls February 31 over to March 3 (2026 is not a leap year, so February ends on the 28th).
const d = new Date(2026, 0, 31);
d.setMonth(d.getMonth() + 1);
// Tue Mar 03 2026
If you need “the same day next month” starting from the last day of a month, you have to write your own logic that clamps to the end of the month before the rollover happens.
Also note that the day of the month (1–31) comes from getDate(), while getDay() returns the day of the week (Sunday is 0). The names are similar enough to mix up.
How to handle date-only values
For dates without a time — birthdays, deadlines, reservation dates — there are two approaches: keep them as strings, or standardize on midnight local time.
Approach 1: Keep them as YYYY-MM-DD strings
If all you do is save, compare and pass dates around, not converting them to Date at all is the most reliable option. Zero-padded strings like "2026-11-26" compare in the same order as the dates themselves, even as plain strings.
"2026-11-26" < "2026-12-01" // true
A date field’s value, JSON from an API and a database DATE column can all exchange values in this format.
Approach 2: If you use Date, use local time both when creating and when reading
If you need a Date to get the day of the week or add days, split the string yourself and build it at midnight local time.
function parseYmd(s) {
const [y, m, d] = s.split("-").map(Number);
return new Date(y, m - 1, d); // subtract 1 from the month only
}
When writing it back out, build the string from the local-time values instead of using toISOString().
function formatYmd(d) {
const y = d.getFullYear();
const m = String(d.getMonth() + 1).padStart(2, "0"); // add 1 to the month
const day = String(d.getDate()).padStart(2, "0");
return `${y}-${m}-${day}`;
}
Go through these two functions and parseYmd("2026-11-26") becomes midnight on the 26th in any time zone, and formatYmd turns it back into "2026-11-26". The key is to use the same reference time zone when creating and when reading; making only one side UTC is what creates the shift.
You’ll also find d.toLocaleDateString("sv-SE") recommended online as a way to get YYYY-MM-DD. It relies on the fact that Swedish date notation happens to use this format, and on my machine it returned "2026-11-26". But each language’s notation depends on the locale data the browser uses, so I recommend the functions above, whose intent is easier to read.
For instants, store UTC and pick the region when displaying
For data that represents “the same moment no matter where in the world you look” — log timestamps, the start time of a booking — the situation is reversed. Store these as UTC times or Unix timestamps, and decide the region just before displaying them. toISOString() is made for exactly this purpose and works correctly as a storage string.
When displaying, passing timeZone to Intl.DateTimeFormat or toLocaleString() lets you format the time for a specific region regardless of the runtime’s settings. (The example uses the ja-JP locale, which formats dates as YYYY/MM/DD; the timeZone option works the same with any locale.)
const t = new Date("2026-11-26T09:00:00Z");
t.toLocaleString("ja-JP", { timeZone: "Asia/Tokyo" }); // "2026/11/26 18:00:00"
t.toLocaleString("ja-JP", { timeZone: "America/New_York" }); // "2026/11/26 4:00:00"
In server-side Node.js, if you don’t specify a time zone, the runtime’s setting is used. Containers and cloud runtimes are often set to UTC, so getDate() that was correct on a development PC (Japan time) can return the date from nine hours earlier in production. For code that handles dates on a server, running your tests with TZ=UTC and TZ=America/New_York catches all of the shifts described so far in one go.
TZ=UTC node app.js
TZ=America/New_York node app.js
When receiving times as strings, including the offset, as in "2026-11-26T18:00:00+09:00", makes the interpretation the same in every environment. Converting to and from Unix timestamps is covered in Read Unix timestamps in JST and set the start of a log search, and offsets between regions and daylight saving time transitions in Japan–US time difference: how to pick meeting times across time zones, and why they shift in March and November.
Temporal, the new API
In response to these problems, a new API called Temporal, which handles dates and times as separate types, is being implemented. A date without a time is represented by Temporal.PlainDate, so the date never changes with the time zone. Months count from 1, too.
const d = Temporal.PlainDate.from("2026-11-26");
d.day; // 26 (26 even in the New York time zone)
d.month; // 11
Temporal.PlainDate.from("2026-01-31").add({ months: 1 }).toString(); // "2026-02-28"
Another difference from Date is that one month after January 31 stays at February 28 instead of rolling over into March. I checked the results above in Chromium 158, but in Node.js 22 at the same point in time Temporal was undefined. Availability depends on the runtime, so check it on your target browsers and runtimes before adopting it.
Quick reference: from symptom to cause
| Symptom | Main cause | Fix |
|---|---|---|
new Date("2026-11-26") lands at 9:00, or on the previous day overseas |
Date-only strings are read as UTC | Keep it as a string, or build it with new Date(y, m - 1, d) |
toISOString().slice(0, 10) gives the previous day (0:00–8:59 Japan time) |
toISOString() writes in UTC |
Build YYYY-MM-DD from the local-time values |
| A date field’s value becomes one day earlier overseas | valueAsDate is midnight UTC |
Use the value string |
getMonth() returns 10 in November; specifying December gives January next year |
Months start at 0 and out-of-range values roll over | Subtract 1 when creating, add 1 when reading |
| One month after January 31 is March 3 | setMonth causes the day to roll over |
Clamp to the end of the month, or use Temporal.PlainDate |
| Correct in development, nine hours off only on the production server | The runtime’s time zone is UTC | Specify timeZone when displaying; test with different TZ values |
If dates you receive from Excel show up as numbers like 46357, you need a different conversion from the shifts covered here. I explained how to turn serial numbers back into dates in Why Excel dates turn into numbers (in Japanese).
Reproducing it yourself
If you have Node.js installed, save the following as date-check.js and run it in different time zones to confirm the results in this article.
console.log(new Date("2026-11-26").toString());
console.log(new Date("2026-11-26T00:00").toString());
console.log(new Date(2026, 10, 26).toISOString());
console.log(new Date(2026, 11, 26).toString());
const d = new Date(2026, 0, 31);
d.setMonth(d.getMonth() + 1);
console.log(d.toString());
TZ=Asia/Tokyo node date-check.js
TZ=America/New_York node date-check.js
TZ=UTC node date-check.js
With TZ=UTC, the first and second lines show the same time, and the third line doesn’t fall on the previous day either. This is why a server defaulting to UTC hides the problem. Trying both Japan time and New York time also lets you see that the shift goes in opposite directions.