JavaScript Date()
The Date() constructor creates Date objects.
Date objects represent dates and times.
JavaScript stores dates as the number of milliseconds since January 1, 1970 UTC.
Syntax
new Date()
new Date(milliseconds)
new Date(dateString)
new Date(year, month)
new Date(year, month, day)
new Date(year, month, day, hours, minutes, seconds, milliseconds)
Date()
Parameters
| Parameter | Description |
|---|---|
| milliseconds | Milliseconds since January 1, 1970 UTC. |
| dateString | A date string. |
| year, month, day, ... | Date and time components. |
Return Value
| Call | Returns |
|---|---|
Date() |
A date-time string |
new Date() |
A Date object |
Date() vs new Date()
Calling Date() as a function returns a string.
Calling new Date() creates a Date object.
Example
let a = Date();
let b = new Date();
(typeof a) // string
(typeof b) // object
Current Date
Date(); // returns string
new Date(); // returns Date object
Creating Dates
Current Date
const d = new Date();
From String
const d = new Date("2025-12-24");
From Parameters
const d = new Date(2025, 11, 24);
Timestamps
Date objects internally store a timestamp.
Current Date
const d = new Date();
d.getTime();
Object Hierarchy
Date objects inherit from Object.
Object └─ Date
| Constructor Type | Function |
| Creates | Date objects |
| Inherits From | Object |
Common Properties and Methods
getTime()getFullYear()getMonth()getDate()toISOString()toLocaleDateString()
Type Information
| Property | Value |
|---|---|
| Constructor Type | Function |
| Creates | Date objects |
| Inherits From | Object |
Months are zero-based.
January is 0 and December is 11.
Current Date
new Date(2025, 0, 1); // Jan 1, 2025
new Date(2025, 11, 1); // Dec 1, 2025
Related Pages:
Browser Support
new Date() is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera |