There are several crazy things that happen with a JS DATE object that convert strings, for example consider the following date you provided

Note: The following examples may or may not be ONE DAY OFF depending on YOUR timezone and current time.

new Date("2011-09-24"); // Year-Month-Day
// => Fri Sep 23 2011 17:00:00 GMT-0700 (MST) - ONE DAY OFF.

However, if we rearrange the string format to Month-Day-Year...

new Date("09-24-2011");
// => Sat Sep 24 2011 00:00:00 GMT-0700 (MST) - CORRECT DATE.

Another strange one

new Date("2011-09-24");
// => Fri Sep 23 2011 17:00:00 GMT-0700 (MST) - ONE DAY OFF AS BEFORE.

new Date("2011/09/24"); // change from "-" to "/".
// => Sat Sep 24 2011 00:00:00 GMT-0700 (MST) - CORRECT DATE.

We could easily change hyphens in your date "2011-09-24" when making a new date

new Date("2011-09-24".replace(/-/g, '\/')); // => "2011/09/24".
// => Sat Sep 24 2011 00:00:00 GMT-0700 (MST) - CORRECT DATE.

What if we had a date string like "2011-09-24T00:00:00"

new Date("2011-09-24T00:00:00");
// => Fri Sep 23 2011 17:00:00 GMT-0700 (MST) - ONE DAY OFF.

Now change hyphen to forward slash as before; what happens?

new Date("2011/09/24T00:00:00");
// => Invalid Date.

I typically have to manage the date format 2011-09-24T00:00:00 so this is what I do.

new Date("2011-09-24T00:00:00".replace(/-/g, '\/').replace(/T.+/, ''));
// => Sat Sep 24 2011 00:00:00 GMT-0700 (MST) - CORRECT DATE.

UPDATE

If you provide separate arguments to the Date constructor you can get other useful outputs as described below

Note: arguments can be of type Number or String. I'll show examples with mixed values.

Get the first month and day of a given year

new Date(2011, 0); // Normal behavior as months in this case are zero based.
// => Sat Jan 01 2011 00:00:00 GMT-0700 (MST)

Get the last month and day of a year

new Date((2011 + 1), 0, 0); // The second zero roles back one day into the previous month's last day.
// => Sat Dec 31 2011 00:00:00 GMT-0700 (MST)

Example of Number, String arguments. Note the month is March because zero based months again.

new Date(2011, "02"); 
// => Tue Mar 01 2011 00:00:00 GMT-0700 (MST)

If we do the same thing but with a day of zero, we get something different.

new Date(2011, "02", 0); // Again the zero roles back from March to the last day of February.
// => Mon Feb 28 2011 00:00:00 GMT-0700 (MST)

Adding a day of zero to any year and month argument will get the last day of the previous month. If you continue with negative numbers you can continue rolling back another day

new Date(2011, "02", -1);
// => Sun Feb 27 2011 00:00:00 GMT-0700 (MST)
Answer from SoEzPz on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_dates.asp
W3Schools.com
February 4, 2026 - By default, JavaScript will use the browser's time zone and display a date as a full text string: You will learn much more about how to display dates, later in this tutorial. Date objects are created with the new Date() ...
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Date โ€บ Date
Date() constructor - JavaScript | MDN
If the Date() constructor is called with one parameter which is not a Date instance, it will be coerced to a primitive and then checked whether it's a string. For example, new Date(undefined) is different from new Date(): js ยท console.log(new Date(undefined)); // Invalid Date ยท
Discussions

Is the Javascript date object always one day off? - Stack Overflow
In my Javascript app I have the date stored in a format like so: 2011-09-24 Now when I try using the above value to create a new Date object (so I can retrieve the date in a different format), the... More on stackoverflow.com
๐ŸŒ stackoverflow.com
typescript - Which time zone does JavaScript `new Date()` use? - Stack Overflow
I have a C# application that return in JSON an expiration date of an authentication token like this: "expirationDate":"Fri, 27 Mar 2015 09:12:45 GMT" In my TypeScript I check that the date is still More on stackoverflow.com
๐ŸŒ stackoverflow.com
Date vs new Date in JavaScript - Stack Overflow
Create a Date Object as intended by the designers of the spec, don't code to the workarounds implemented as safeguards by engineers that think JS programmers are stupid. (worked in the lab, was in the next chair during the conversation, dealt with it and moved on) If you are madly against new you ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
new Date vs. new Date() - Is there any difference?
Read this stackoverflow thread . More on reddit.com
๐ŸŒ r/javascript
4
2
January 19, 2015
๐ŸŒ
Visual Studio Code
code.visualstudio.com
Visual Studio Code - The open source AI code editor
"true" : undefined} > <div> <div class="mail-item-subject truncate">{e.subject}</div> <div class="mail-item-snippet truncate">{e.snippet}</div> </div> <time class="text-xs muted" datetime={e.date} title={new Date(e.date).toLocaleString()} > {new Date(e.date).toLocaleDateString(undefined, { month: "short", day: "numeric", })} </time> </div> <MailListItem email={e} isSelected={params.id === e.id} onOpen={open} /> )} </For> ); }
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Date
Date - JavaScript | MDN
This also applies to dates specified with the date time string format. When attempting to set the local time to a time falling within an offset transition (usually daylight saving time), the exact time is derived using the same behavior as Temporal's disambiguation: "compatible" option. That is, if the local time corresponds to two instants, the earlier one is chosen; if the local time does not exist (there is a gap), we go forward by the gap duration. js ยท // Assume America/New_York local time zone // 2024-03-10 02:30 is within the spring-forward transition and does not exist // 01:59 (UTC-5
๐ŸŒ
Bugfender
bugfender.com โ€บ blog โ€บ javascript-date-and-time
The Definitive Guide to JavaScript Date and Time | Bugfender
February 18, 2025 - It is used for converting between Date JS objects and epoch timestamps and performing other advanced operationsโ€‹. The most common way to create a Date object in JavaScript is by using the new Date() constructor, which returns the current date ...
Find elsewhere
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Date โ€บ now
Date.now() - JavaScript | MDN
The Date.now() static method returns the number of milliseconds elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.
๐ŸŒ
The New Yorker
newyorker.com โ€บ culture โ€บ leukemia โ€บ a battle with my blood
Tatiana Schlossberg on Being Diagnosed with Leukemia After Giving Birth | The New Yorker
November 22, 2025 - On May 25, 2024, my daughter was born at 7:05 in the morning, ten minutes after I arrived at Columbia-Presbyterian hospital, in New York. My husband, George, and I held her and stared at her and admired her newness.
Top answer
1 of 16
550

There are several crazy things that happen with a JS DATE object that convert strings, for example consider the following date you provided

Note: The following examples may or may not be ONE DAY OFF depending on YOUR timezone and current time.

new Date("2011-09-24"); // Year-Month-Day
// => Fri Sep 23 2011 17:00:00 GMT-0700 (MST) - ONE DAY OFF.

However, if we rearrange the string format to Month-Day-Year...

new Date("09-24-2011");
// => Sat Sep 24 2011 00:00:00 GMT-0700 (MST) - CORRECT DATE.

Another strange one

new Date("2011-09-24");
// => Fri Sep 23 2011 17:00:00 GMT-0700 (MST) - ONE DAY OFF AS BEFORE.

new Date("2011/09/24"); // change from "-" to "/".
// => Sat Sep 24 2011 00:00:00 GMT-0700 (MST) - CORRECT DATE.

We could easily change hyphens in your date "2011-09-24" when making a new date

new Date("2011-09-24".replace(/-/g, '\/')); // => "2011/09/24".
// => Sat Sep 24 2011 00:00:00 GMT-0700 (MST) - CORRECT DATE.

What if we had a date string like "2011-09-24T00:00:00"

new Date("2011-09-24T00:00:00");
// => Fri Sep 23 2011 17:00:00 GMT-0700 (MST) - ONE DAY OFF.

Now change hyphen to forward slash as before; what happens?

new Date("2011/09/24T00:00:00");
// => Invalid Date.

I typically have to manage the date format 2011-09-24T00:00:00 so this is what I do.

new Date("2011-09-24T00:00:00".replace(/-/g, '\/').replace(/T.+/, ''));
// => Sat Sep 24 2011 00:00:00 GMT-0700 (MST) - CORRECT DATE.

UPDATE

If you provide separate arguments to the Date constructor you can get other useful outputs as described below

Note: arguments can be of type Number or String. I'll show examples with mixed values.

Get the first month and day of a given year

new Date(2011, 0); // Normal behavior as months in this case are zero based.
// => Sat Jan 01 2011 00:00:00 GMT-0700 (MST)

Get the last month and day of a year

new Date((2011 + 1), 0, 0); // The second zero roles back one day into the previous month's last day.
// => Sat Dec 31 2011 00:00:00 GMT-0700 (MST)

Example of Number, String arguments. Note the month is March because zero based months again.

new Date(2011, "02"); 
// => Tue Mar 01 2011 00:00:00 GMT-0700 (MST)

If we do the same thing but with a day of zero, we get something different.

new Date(2011, "02", 0); // Again the zero roles back from March to the last day of February.
// => Mon Feb 28 2011 00:00:00 GMT-0700 (MST)

Adding a day of zero to any year and month argument will get the last day of the previous month. If you continue with negative numbers you can continue rolling back another day

new Date(2011, "02", -1);
// => Sun Feb 27 2011 00:00:00 GMT-0700 (MST)
2 of 16
165

Notice that Eastern Daylight Time is -4 hours and that the hours on the date you're getting back are 20.

20h + 4h = 24h

which is midnight of 2011-09-24. The date was parsed in UTC (GMT) because you provided a date-only string without any time zone indicator. If you had given a date/time string w/o an indicator instead (new Date("2011-09-24T00:00:00")), it would have been parsed in your local timezone. (Historically there have been inconsistencies there, not least because the spec changed more than once, but modern browsers should be okay; or you can always include a timezone indicator.)

You're getting the right date, you just never specified the correct time zone.

If you need to access the date values, you can use getUTCDate() or any of the other getUTC*() functions:

var d,
  days;
d = new Date('2011-09-24');
days = ['Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat'];
console.log(days[d.getUTCDay()]);

๐ŸŒ
ApexCharts
apexcharts.com โ€บ home
ApexCharts.js - Open Source JavaScript Charts for your website
March 7, 2020 - Get the latest news, updates and what's coming next!
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ javascript-date-objects
JavaScript Date Objects - GeeksforGeeks
July 11, 2025 - ... let cDate = new Date(); console.log(cDate.getFullYear()); // Gets the current year console.log(cDate.getMonth()); // Gets the current month (0-indexed) console.log(cDate.getDate()); // Gets the current day of the month console.log(cDate...
Top answer
1 of 4
23

JavaScript will use the client's local time but it also has UTC / GMT methods. The following is from Mozilla:

The JavaScript Date object supports a number of UTC (universal) methods, as well as local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the time as set by the World Time Standard. The local time is the time known to the computer where JavaScript is executed.

While methods are available to access date and time in both UTC and the localtime zone, the date and time are stored in the local time zone:

Note: It's important to keep in mind that the date and time is stored in the local time zone, and that the basic methods to fetch the date and time or its components all work in the local time zone as well.

Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

2 of 4
4

What time zone does the Javascript new Date() use?

Date objects store the number of milliseconds since The Epoch (Jan 1st 1970 at midnight GMT). They have methods like getDay and getMonth and such that provide values in the local timezone, and also functions like getUTCDay and getUTCMonth that provide values in UTC (loosely, GMT).

If you're parsing a string, you need to be sure that the string is in a format that Date knows how to parse. The only defined format in the specification is a simplified derivative of ISO-8601: YYYY-MM-DDTHH:mm:ss.sssZ. But that was only added in ES5 (and then updated in ES2015 and ES2016). The time zone of the string is determined by whether it has a UTC offset indicator (Z, -08:00, +05:30, etc.) and whether it's date-only or date/time. Here are some examples:

function test(str) {
    const dt = new Date(str);
    const p = document.createElement("pre");
    p.textContent =
        `String: "${str}"\n` +
        `UTC:    ${dt.toISOString()}\n` +
        `Local:  ${dt.toLocaleString()}`
    ;
    document.body.appendChild(p);
}

// No UTC offset provided, date-only form => parsed as UTC:
test("2015-08-09");

// No UTC offset provided, date/time form => parsed as local time:
test("2015-08-09T09:32:54");

// Has UTC offset "Z" (for "no offset") => parsed as UTC:
test("2015-08-09T09:32:54.427Z");

// Has UTC offset -08:00 => parsed as UTC minus eight hours:
test("2015-08-09T09:32:54.427-08:00");


I don't recommend relying on it, but even though it's not specified, all major JavaScript engines will successfully parse the American-specific formats MM/DD/YYYY, MM/DD/YYYY hh:mm, MM/DD/YYYY hh:mm:ss, or MM/DD/YYYY hh:mm:ss.SSS (although the milliseconds portion is ignored by some). Note the order in the date portion: month, day, year. Having a UTC offset indicator is not broadly supported and will cause an error on most engines, so don't include one. Without one, all of those are parsed as local time (even the date-only one). Note that the date field separator must be / (08/09/2015), not - (08-09-2015).

function test(str) {
    const dt = new Date(str);
    const p = document.createElement("pre");
    p.textContent =
        `String: "${str}"\n` +
        `UTC:    ${dt.toISOString()}\n` +
        `Local:  ${dt.toLocaleString()}`
    ;
    document.body.appendChild(p);
}

test("08/09/2015");
test("08/09/2015 09:32");
test("08/09/2015 09:32:54");
test("08/09/2015 09:32:54.427");

But again: I don't recommend relying on that.

๐ŸŒ
JetBrains
jetbrains.com โ€บ idea โ€บ whatsnew
What's New in IntelliJ IDEA
Monitoring and managing your AI resources just got a lot easier, as you can now view your remaining AI Credits, renewal date, and top-up balance directly inside IntelliJ IDEA.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ difference-between-new-date-and-datenow-in-javascript
Difference Between new Date() and Date.now() in JavaScript - GeeksforGeeks
August 5, 2025 - The new Date() constructor in JavaScript creates a new Date object that represents the current date and time or specifies the date and time.
๐ŸŒ
Tailwind CSS
tailwindcss.com โ€บ blog โ€บ tailwindcss-v4
Tailwind CSS v4.0 - Tailwind CSS
January 22, 2025 - The new CSS-first configuration lets you do just about everything you could do in your tailwind.config.js file, including configuring your design tokens, defining custom utilities and variants, and more.
๐ŸŒ
Oracle
java.com โ€บ en โ€บ download โ€บ manual.jsp
Download Java
ยป What is Java ยป Remove older versions ยป Security ยป Support ยป Other help ยท This download is for end users who need Java for running applications on desktops or laptops. Java 8 integrates with your operating system to run separately installed Java applications.
๐ŸŒ
Reddit
reddit.com โ€บ r/javascript โ€บ new date("wtf") - how well do you know javascript's date class?
r/javascript on Reddit: new Date("wtf") - How well do you know JavaScript's Date class?
July 12, 2025 - Edit: In fact, new Date("0") is a perfect illustration of this. Depending on which JS engine you use, you get a different answer. Chrome/NodeJS and Firefox give midnight in your device's timezone on 2000-01-01.