Clean β’ Professional
Date objects provide getter methods to retrieve different parts of a date. You can get the year, month, day, hours, minutes, seconds, milliseconds, and day of the week.
These methods come in local time and UTC variants.

getFullYear() β Get the YearThe getFullYear() method returns the four-digit year of a date object.
Example:
const d = new Date("2025-10-08T18:30:00");
console.log(d.getFullYear());
// 2025
getMonth() β Get the MonthgetMonth() returns the month of the date, but months are 0-indexed, meaning January = 0 and December = 11.
Example:
const d = new Date("2025-10-08");
console.log(d.getMonth());
// 9 β October (0 = January)
getDate() β Get the Day of the MonthgetDate() returns the day of the month (1β31).
const d = new Date("2025-10-08");
console.log(d.getDate());
// 8
getDay() β Get the Day of the WeekgetDay() returns the day of the week as a number (0β6).
Example:
const d = new Date("2025-10-08");
console.log(d.getDay());
// 3 β Wednesday (0 = Sunday)
getHours() β Get HoursgetHours() returns the hour of the day (0β23) in local time.
Example:
const d = new Date("2025-10-08T18:30:00");
console.log(d.getHours());
// 18
getMinutes() β Get MinutesgetMinutes() returns minutes (0β59).
Example:
const d = new Date("2025-10-08T18:30:45");
console.log(d.getMinutes());
// 30
getSeconds() β Get SecondsgetSeconds() returns the seconds (0β59) of a date object.
Example:
const d = new Date("2025-10-08T18:30:45");
console.log(d.getSeconds());
// 45
getMilliseconds() β Get MillisecondsgetMilliseconds() returns milliseconds (0β999).
Example:
const d = new Date("2025-10-08T18:30:45.123");
console.log(d.getMilliseconds());
// 123
getTime() β Get TimestampgetTime() returns the number of milliseconds since January 1, 1970, 00:00:00 UTC (Unix Epoch).
Example:
const d = new Date("2025-10-08T18:30:00");
console.log(d.getTime());
// 1759917000000
getTimezoneOffset() β Get Time Zone DifferencegetTimezoneOffset() returns the difference in minutes between local time and UTC.
Example:
const d = new Date("2025-10-08T18:30:00");
console.log(d.getTimezoneOffset());
// -330 β IST is UTC+5:30
| Method | Returns | UTC Variant | Use Case / Notes |
|---|---|---|---|
getFullYear() | 4-digit year | getUTCFullYear() | Display year, calculate age |
getMonth() | Month (0β11) | getUTCMonth() | Month-based calculations, formatted display |
getDate() | Day of month (1β31) | getUTCDate() | User-friendly dates, due dates |
getDay() | Day of week (0β6) | getUTCDay() | Weekly schedules, calendar apps |
getHours() | Hours (0β23) | getUTCHours() | Event scheduling, reminders |
getMinutes() | Minutes (0β59) | getUTCMinutes() | Time formatting (HH:MM) |
getSeconds() | Seconds (0β59) | getUTCSeconds() | Timers, animations |
getMilliseconds() | Milliseconds (0β999) | getUTCMilliseconds() | High-precision timing |
getTime() | Milliseconds since Epoch | N/A | Timestamp comparisons, calculations |
getTimezoneOffset() | Minutes offset from UTC | N/A | Time zone conversions |
Β