Js Date Get Methods in JavaScript
? JavaScript Date Get Methods
JavaScript's Date object provides several getter methods to extract parts of a date/time.
Common Date Get Methods
| Method | Description | Returns |
|---|---|---|
getFullYear() | Gets the 4-digit year | 2025 |
getMonth() | Gets the month (0–11) | 0 = Jan, 5 = June |
getDate() | Gets the day of the month (1–31) | 1 to 31 |
getDay() | Gets the day of the week (0–6) | 0 = Sunday, 6 = Saturday |
getHours() | Gets the hour (0–23) | 0 to 23 |
getMinutes() | Gets the minutes (0–59) | 0 to 59 |
getSeconds() | Gets the seconds (0–59) | 0 to 59 |
getMilliseconds() | Gets milliseconds (0–999) | 0 to 999 |
getTime() | Gets timestamp (ms since Unix epoch) | Number |
Example
const now = new Date();console.log(now.getFullYear()); // e.g. 2025console.log(now.getMonth()); // 0–11 (e.g. 5 for June)console.log(now.getDate()); // 1–31console.log(now.getDay()); // 0–6 (0 = Sunday)console.log(now.getHours()); // 0–23console.log(now.getMinutes()); // 0–59console.log(now.getSeconds()); // 0–59console.log(now.getMilliseconds()); // 0–999console.log(now.getTime()); // e.g. 1754294400000 (milliseconds since 1970-01-01)Notes
Months are zero-based (January = 0).
Days of the week start at Sunday = 0.
Use
.getTime()for date comparisons or storing timestamps.
Want me to cover the corresponding set methods for modifying dates or UTC versions of these getters?