🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN - Mozilla
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

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
Format JavaScript date as yyyy-mm-dd - Stack Overflow
Related: What are valid Date Time Strings in JavaScript? Note that "Sun May 11,2014" is not a valid date string and parsing it might fail in some browsers. ... Where yourDate is your date object. More on stackoverflow.com
🌐 stackoverflow.com
A simple guide to JavaScript Dates
The date constructor in JS has screwed with me more times than I care to admit More on reddit.com
🌐 r/javascript
42
150
July 9, 2018
How to combine a date object with a time string and convert to UTC?
eg: var date = new Date(); var time = '13:31:59'; var timeSplit = time.split(':'); date.setHours(timeSplit[0]); date.setMinutes(timeSplit[1]); date.setSeconds(timeSplit[2]); var utcDateTime = [date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()].join('-') + ' ' + [date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()].join(':') + 'Z'; // eg "2020-5-24 11:31:59Z" using vanilla js date: https://www.w3schools.com/jsref/jsref_obj_date.asp this takes the local date/ time and convert it into UTC dateTime or use a wrapper libray such as moment or date-fns More on reddit.com
🌐 r/vuejs
4
3
March 26, 2020
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript - MDN - Mozilla
The Date() constructor creates Date objects. When called as a function, it returns a string representing the current 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:
🌐
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
🌐
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_date_methods.asp
JavaScript Get 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()....
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-date-objects
JavaScript Date Objects - GeeksforGeeks
July 11, 2025 - In JavaScript, the Date object is a built-in object that allows you to work with dates and times.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Representing_dates_times
Representing dates & times - JavaScript | MDN - Mozilla
JavaScript does not have a date data type. However, you can use the Date object and its methods to work with dates and times in your applications. The Date object has a large number of methods for setting, getting, and manipulating dates. It does not have any properties.
🌐
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.
🌐
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.
🌐
Unibo
lia.disi.unibo.it › materiale › JS › developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date.html
Date - JavaScript | MDN
Creates a JavaScript Date instance that represents a single moment in time. Date objects are based on a time value that is the number of milliseconds since 1 January, 1970 UTC.
🌐
University of Washington
cev.washington.edu › lc › CLWEBCLB › jst › js_datetime.html
JavaScript Date Object
HTML,CSS,JavaScript,DHTML,XML,XHTML,ASP,ADO and VBScript tutorial from W3Schools.
🌐
Simon Willison
til.simonwillison.net › javascript › javascript-date-objects
JavaScript date objects | Simon Willison’s TILs
I wanted to calculate the number of minutes difference between a start date and an end date. Subtracting the two gives you a difference between them as in integer number of milliseconds! So this gives you minutes: let diff = end.getTime() - start.getTime(); let minutes = Math.round(diff / 60 * 1000); The closest JavaScript gets to Python's handy strftime() method is the much more unwieldly toLocaleDateString() method.
Top answer
1 of 16
1588

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.

🌐
CodingNomads
codingnomads.com › introduction-javascript-date-object
Beginners Guide to the Date Object in JavaScript
In JavaScript, the Date object serves as a component for handling dates and times. It's a built-in global object, meaning it's available in all browser JavaScript environments as part of the window.
🌐
Bugfender
bugfender.com › blog › javascript-date-and-time
The Definitive Guide to JavaScript Date and Time | Bugfender
February 18, 2025 - Learn multiple ways to create, format, and manipulate Date objects. Discover methods for getting the current date in various formats. Explore advanced topics like calculating elapsed time and handling time zones. Gain insights into popular JavaScript libraries for improved date and time handling.
🌐
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.