🌐
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.
🌐
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).
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
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 12, 2014
Why does the Javascript Date object use a zero-based index for the month?
Things are indexed from 0 in computer science. It was chosen to abide by this rather than to index months from 1. Why was this decision made? I don't know. More on reddit.com
🌐 r/learnprogramming
9
4
September 12, 2010
🌐
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>
🌐
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.
🌐
DEV Community
dev.to › amitkhonde › javascript-date-object-simplified-453m
JavaScript Date Object Simplified - DEV Community
July 6, 2021 - Date object in javascript represents a given point in time. It has everything you can associate with time.
🌐
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.
Find elsewhere
🌐
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.
🌐
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
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.
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()]);

🌐
freeCodeCamp
freecodecamp.org › news › how-to-validate-a-date-in-javascript
JS Date Validations – How To Validate a Date in JavaScript (With Examples)
August 22, 2023 - There are times when you need to ... in your JavaScript applications. This article will show you how to perform the following date validations: ... Validating a date value helps you prevent users from entering an incorrect date. Let's start with validating the input itself. To validate if a string is a valid date input, you need to call the Date() constructor and pass the string as its argument. If the string is a valid date, the constructor returns a Date object holding the ...
🌐
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.
🌐
Code Snippet
codesnippet.io › date
Date Object | CodeSnippet.io | JavaScript Tips & Tricks
October 23, 2018 - The JavaScript Date object is a way to utilize dates and times within your web application.
🌐
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()....
🌐
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.