🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
JavaScript Date objects represent a single moment in time in a platform-independent format. Date objects encapsulate an integral number that represents milliseconds since the midnight at the beginning of January 1, 1970, UTC (the epoch).
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript date object
JavaScript Date Object
September 1, 2008 - If you pass the positive milliseconds as an argument, the object returns the date according to the 1st January 1970 00:00:00 + milliseconds. Otherwise, it returns the date according to the 1st January 1970 00:00:00 milliseconds if negative milliseconds passed as an argument. <html> <head> <title> JavaScript - Date object </title> </head> <body> <p id = "output"> </p> <script> const output = document.getElementById("output"); let date = new Date(999999999999); output.innerHTML += "The Date after 1st January, 1970 is - " + date + "<br>"; date = new Date(-999999999999); output.innerHTML += "The Date before 1st January, 1970 is - " + date; </script> </body> </html>
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
javascript - How to check whether an object is a date? - Stack Overflow
I have an annoying bug in on a webpage: date.GetMonth() is not a function So, I suppose that I am doing something wrong. The variable date is not an object of type Date. How can I check for a dat... More on stackoverflow.com
🌐 stackoverflow.com
How to REALLY get a UTC Date object : javascript
🌐 r/javascript
How to REALLY get a UTC Date object

var date = new Date('2015-10-11T14:03:19.243Z'); var str = date.toISOString();

More on reddit.com
🌐 r/javascript
6
1
February 14, 2014
🌐
Oracle
docs.oracle.com › en › industries › life-sciences › clinical-one › rules-dg › standard-javascript-date-object.html
The standard JavaScript Date object
December 18, 2025 - The Date object is a standard built-in JavaScript object and supports full dates only. This object has built-in methods that can be used to retrieve specific date components.
🌐
DEV Community
dev.to › random_ti › javascript-date-object-is-finally-being-replaced-d10
JavaScript Date object is finally being replaced 😱 - DEV Community
May 1, 2025 - This new JavaScript feature makes working with dates and times easier and more reliable than the old Date object.
🌐
DigitalOcean
digitalocean.com › community › tutorials › understanding-date-and-time-in-javascript
Understanding Date and Time in JavaScript | DigitalOcean
August 25, 2021 - This tutorial will go over how to format and use date and time in JavaScript. The Date object is a built-in object in JavaScript that stores the date and time.
🌐
W3Schools
w3schools.com › js › js_dates.asp
JavaScript Dates
February 4, 2026 - JavaScript stores dates as number of milliseconds since January 01, 1970. Zero time is January 01, 1970 00:00:00 UTC. One day (24 hours) is 86 400 000 milliseconds. Now the time is: milliseconds past January 01, 1970 · new Date(milliseconds) creates a new date object as milliseconds plus zero time:
🌐
Codecademy
codecademy.com › article › javascript-date-format
How to Format a Date in JavaScript | Codecademy
In JavaScript, the Date() constructor returns a new Date object representing the current date or a specific date. If we create a Date object without any input parameters, it contains the current date and time along with the timezone details.
Find elsewhere
🌐
Toptal
toptal.com › developers › software › definitive-guide-to-datetime-manipulation
How to get the Timestamp And Date in Javascript: JS DateTime | Toptal®
December 2, 2020 - Fortunately, modern JavaScript has some convenient internationalization functions built into the standard Intl namespace that make date formatting a straightforward operation. For this we’ll need two objects: a Date and an Intl.DateTimeFormat, initialized with our output preferences.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getTime
Date.prototype.getTime() - JavaScript | MDN
July 10, 2025 - The getTime() method of Date instances returns the number of milliseconds for this date since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.
🌐
Devwares
devwares.com › blog › javascript-date-object
Javascript Date Objects
May 12, 2024 - The year, month, day, hour, minute, second, and millisecond of date objects can be retrieved and set using either local or UTC (universal, or GMT) time. ... By default, JavaScript outputs dates in full text string format: 01:00:00 GMT+0100 on Wednesday, March 25th, 2015 (West Africa Standard Time) When you display a date object in HTML, the toString() method converts it to a string automatically.
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()]);

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript | MDN
The Date() constructor creates Date objects. When called as a function, it returns a string representing the current time.
🌐
DEV Community
dev.to › thinkster › don-t-use-the-date-object-216n
Don't Use The Date Object - DEV Community
November 16, 2020 - JavaScript has a nice Date Object. It can do all kinds of cool things like tell you the current date... Tagged with javascript, webdev, productivity, tech.
🌐
Wellesley College
cs.wellesley.edu › ~cs115 › readings › date-objects.html
Date Objects
Imagine that your web page would like to be aware of the current date. You could be prompting the user for time-related values such as month, hour and minute but it would be better to dynamically compute the date and determine, say, whether it is spring or lunchtime and so forth.
🌐
W3Schools
w3schools.com › js › js_date_methods.asp
JavaScript Date Methods
JS Examples JS HTML DOM JS HTML ... Prep JS Bootcamp JS Certificate JS Reference ... In JavaScript, date objects are created with new Date()....
🌐
Talent500
talent500.com › blog › javascript-date-object-methods-time-zones
JavaScript Date Object: Methods, Time Zones & Usage Guide
June 17, 2025 - In this example, new Date() creates a Date object that holds the current date and time based on the computer clock where your JavaScript code is running. However, if you run these same code snippets in different environments, you will see different output.
🌐
W3Schools
w3schools.com › jsref › jsref_obj_date.asp
JavaScript Date Reference
<a> <abbr> <address> <area> <article> <aside> <audio> <b> <base> <bdo> <blockquote> <body> <br> <button> <canvas> <caption> <cite> <code> <col> <colgroup> <datalist> <dd> <del> <details> <dfn> <dialog> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <footer> <form> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <ins> <input> button <input> checkbox <input> color <input> date <input> datetime <input> datetime-local <input> email <input> file <input> hidden <input> image <input> month <input> number <input> password <input> radio <input> range <input> reset <input> sear
Top answer
1 of 16
1587

As an alternative to duck typing via

typeof date.getMonth === 'function'

you can use the instanceof operator, i.e. But it will return true for invalid dates too, e.g. new Date('random_string') is also instance of Date

date instanceof Date

This will fail if objects are passed across frame boundaries.

A work-around for this is to check the object's class via

Object.prototype.toString.call(date) === '[object Date]'
Be aware, that the instanceof solution doesn't work when using multiple realms:

JavaScript execution environments (windows, frames, etc.) are each in their own realm. This means that they have different built-ins (different global object, different constructors, etc.). This may result in unexpected results. For instance, [] instanceof window.frames[0].Array will return false, because Array.prototype !== window.frames[0].Array.prototype and arrays in the current realm inherit from the former.

2 of 16
223

You can use the following code:

(myvar instanceof Date) // returns true or false
Be aware, that this solution doesn't work when using multiple realms:

JavaScript execution environments (windows, frames, etc.) are each in their own realm. This means that they have different built-ins (different global object, different constructors, etc.). This may result in unexpected results. For instance, [] instanceof window.frames[0].Array will return false, because Array.prototype !== window.frames[0].Array.prototype and arrays in the current realm inherit from the former.

🌐
Suneet Agrawal
agrawalsuneet.github.io › blogs › date-object-in-javascript
Date Object in JavaScript · Suneet Agrawal
August 17, 2023 - The Date object in JavaScript represents a single moment in time. It offers various methods and properties to manipulate, format, and retrieve date and time information.