--- id: javascript-date-get-methods title: "JavaScript Date Get Methods" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["Date getters", "getFullYear", "getMonth", "getDate", "getTime", "Date.now", "getTimezoneOffset"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["javascript", "js", "web", "frontend", "w3schools", "date", "getter"] raw_sources: ["https://www.w3schools.com/js/js_date_methods.asp"] applied_in: [] github_commit: "" --- # [[JavaScript Date Get Methods]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Date Get methods read individual parts out of a `Date` object β€” year, month, day, weekday, hours, minutes, seconds, milliseconds, and the underlying timestamp β€” with month and weekday returned as zero-based numbers. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`new Date()` creates a date object** holding a date and time. Get methods then extract individual components from it. [S1] - **Months are zero-based** β€” `getMonth()` returns `0-11`, where January is 0. [S1] - **Weekdays are zero-based** β€” `getDay()` returns `0-6`, where Sunday is 0. [S1] - **`getTime()` returns the timestamp** β€” milliseconds since January 1, 1970. [S1] - **`Date.now()` is a static method** that returns the current milliseconds since January 1, 1970 (it is a method of `Date`, not of a date instance). [S1] - **`getTimezoneOffset()`** returns the difference, in minutes, between local time and UTC. UTC time is the same as GMT. [S1] - **`getYear()` is deprecated** β€” old code may use it to return a 2-digit year; do not use it. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Number-to-name lookup** β€” because `getMonth()`/`getDay()` return zero-based numbers, map them to readable names through an array indexed by that number. [S1] - **Hardcoded vs current date** β€” the same getter works on a parsed literal (`new Date("2021-03-25")`) or on the current moment (`new Date()`). [S1] - **Derive durations from timestamps** β€” divide `Date.now()` by a precomputed unit (ms per year) to estimate elapsed time. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Creating a date object** [S1] ```javascript const date = new Date(); ``` **getFullYear() β€” year as a four digit number (yyyy)** [S1] ```javascript const d = new Date("2021-03-25"); d.getFullYear(); ``` ```javascript const d = new Date(); d.getFullYear(); ``` **getMonth() β€” month as a number (0-11)** [S1] ```javascript const d = new Date("2021-03-25"); d.getMonth(); ``` ```javascript const d = new Date(); d.getMonth(); ``` You can use an array of names to return the month as a name: [S1] ```javascript const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; const d = new Date("2021-03-25"); let month = months[d.getMonth()]; ``` ```javascript const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; const d = new Date(); let month = months[d.getMonth()]; ``` **getDate() β€” day as a number (1-31)** [S1] ```javascript const d = new Date("2021-03-25"); d.getDate(); ``` ```javascript const d = new Date(); d.getDate(); ``` **getHours() β€” hour (0-23)** [S1] ```javascript const d = new Date("2021-03-25"); d.getHours(); ``` ```javascript const d = new Date(); d.getHours(); ``` **getMinutes() β€” minute (0-59)** [S1] ```javascript const d = new Date("2021-03-25"); d.getMinutes(); ``` ```javascript const d = new Date(); d.getMinutes(); ``` **getSeconds() β€” second (0-59)** [S1] ```javascript const d = new Date("2021-03-25"); d.getSeconds(); ``` ```javascript const d = new Date(); d.getSeconds(); ``` **getMilliseconds() β€” millisecond (0-999)** [S1] ```javascript const d = new Date("2021-03-25"); d.getMilliseconds(); ``` ```javascript const d = new Date(); d.getMilliseconds(); ``` **getDay() β€” weekday as a number (0-6)** [S1] ```javascript const d = new Date("2021-03-25"); d.getDay(); ``` ```javascript const d = new Date(); d.getDay(); ``` You can use an array of names to return the weekday as a name: [S1] ```javascript const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; const d = new Date("2021-03-25"); let day = days[d.getDay()]; ``` ```javascript const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; const d = new Date(); let day = days[d.getDay()]; ``` **getTime() β€” milliseconds since January 1, 1970** [S1] ```javascript const d = new Date("1970-01-01"); d.getTime(); ``` ```javascript const d = new Date("2021-03-25"); d.getTime(); ``` ```javascript const d = new Date(); d.getTime(); ``` **Date.now() β€” current milliseconds since January 1, 1970** [S1] ```javascript let ms = Date.now(); ``` Calculate the number of years since 1970: [S1] ```javascript const minute = 1000 * 60; const hour = minute * 60; const day = hour * 24; const year = day * 365; let years = Math.round(Date.now() / year); ``` **getTimezoneOffset() β€” difference between local time and UTC, in minutes** [S1] ```javascript let diff = d.getTimezoneOffset(); ``` **Date Get Methods** [S1] | Method | Description | |--------|-------------| | getFullYear() | Get **year** as a four digit number (yyyy) | | getMonth() | Get **month** as a number (0-11) | | getDate() | Get **day** as a number (1-31) | | getDay() | Get **weekday** as a number (0-6) | | getHours() | Get **hour** (0-23) | | getMinutes() | Get **minute** (0-59) | | getSeconds() | Get **second** (0-59) | | getMilliseconds() | Get **millisecond** (0-999) | | getTime() | Get **time** (milliseconds since January 1, 1970) | **UTC Date Get Methods** β€” UTC time is the same as GMT. [S1] | Method | Same As | Description | |--------|---------|-------------| | getUTCDate() | getDate() | Returns the UTC date | | getUTCFullYear() | getFullYear() | Returns the UTC year | | getUTCMonth() | getMonth() | Returns the UTC month | | getUTCDay() | getDay() | Returns the UTC day | | getUTCHours() | getHours() | Returns the UTC hour | | getUTCMinutes() | getMinutes() | Returns the UTC minutes | | getUTCSeconds() | getSeconds() | Returns the UTC seconds | | getUTCMilliseconds() | getMilliseconds() | Returns the UTC milliseconds | ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own snippets are the canonical applied examples β€” reading components off both a parsed literal date and the current date, and converting zero-based month/weekday numbers to names via lookup arrays. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Convert a zero-based month number to a readable name (language: JavaScript): ```javascript const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; const d = new Date(); let month = months[d.getMonth()]; ``` Get the current timestamp: ```javascript let ms = Date.now(); ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) The source flags `getYear()` as deprecated and non-standard; `getFullYear()` is the standard replacement. No other contradictions found in the source. [S1] ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[JavaScript Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[JavaScript Date Set Methods]], [[JavaScript Date Methods]], [[JavaScript Dates]] - **μ°Έμ‘° λ§₯락:** Used whenever reading date/time parts out of a Date object for display or computation. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript Date Get Methods β€” https://www.w3schools.com/js/js_date_methods.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Date Get Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).