In JavaScript, a Date is an object that stores one moment in time. Internally that moment is a count of milliseconds since 1 January 1970 UTC. You create a date with new Date() for “now”, or with parts: new Date(2026, 0, 15).
The month argument is zero-based: 0 is January and 11 is December. getDate() is the day of the month (1–31). getDay() is the weekday, and that index starts at 0 for Sunday. Setters such as setDate() change the same object. toISOString() prints a UTC string for APIs.
new Date(2026, 0, 15) is 15 January 2026 in local time. getMonth() returns 0 for that date.
Syntax
JavaScript Syntax
Common ways to create and read a date:
JavaScript
const now = new Date(); // this moment
const birthday = new Date(2026, 0, 15); // 15 Jan 2026, local
const year = birthday.getFullYear(); // 2026
const month = birthday.getMonth(); // 0 (January)
const stamp = Date.now(); // ms since the epoch
const utc = birthday.toISOString(); // UTC text for APIs
Reference
Core Ideas
Ideas every JavaScript Date tutorial builds on:
Idea
Example
Remember
Create
new Date(2026, 0, 15)
Local date; month starts at 0
Month
getMonth()
0 = January, 11 = December
Weekday
getDay()
0 = Sunday … 6 = Saturday
UTC
Date.UTC(2026, 0, 15)
Build a timestamp in UTC
API text
toISOString()
Always a UTC string
Change
setDate(20)
Mutates that Date object
Code
JavaScript Examples
Three short programs that show how Date works in a JS tutorial.
Example 1 — Read year, month, day, and weekday
15 January 2026 in local time. The month index is 0.
A Date is an object that stores one moment as milliseconds since 1 January 1970 UTC (the Unix epoch). You create it with new Date() or new Date(year, month, day), then read parts with getters such as getFullYear().
Months are zero-based: 0 is January and 11 is December. Days of the month from getDate() are 1–31. getDay() is also zero-based, but that index is the weekday: 0 is Sunday.
Yes. setDate(), setMonth(), and the other setters change the same object and return the new timestamp. Copy first with new Date(date.getTime()) when you need to keep the original moment.
getHours() and setHours() use the local timezone. getUTCHours() and Date.UTC() use Coordinated Universal Time. toISOString() always prints UTC, which is the usual form for APIs.
Practice the examples here, then open the Date Methods index for getFullYear(), getMonth(), toISOString(), and Date.now(). The Date Properties index lists constructor, prototype, length, and name.