--- id: javascript-dates title: "JavaScript Dates" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["Date object", "new Date", "Date.now", "date constructor", "JS dates"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.89 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["javascript", "js", "web", "frontend", "w3schools", "date", "time"] raw_sources: ["https://www.w3schools.com/js/js_dates.asp"] applied_in: [] github_commit: "" --- # [[JavaScript Dates]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) JavaScript dates are created with `new Date()` in several argument forms (none, a date string, 2–7 numbers, or milliseconds since the 1970 epoch), and months are counted from 0 (January) to 11 (December). [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`new Date()`** creates a date object with the current date and time. [S1] - **`new Date(date string)`** creates a date from a date string. [S1] - **`new Date(year, month, ...)`** creates a date from numeric components (year, month, day, hours, minutes, seconds, milliseconds). [S1] - **`new Date(milliseconds)`** creates a date as milliseconds since January 1, 1970 (the epoch / zero time). [S1] - **Months are zero-indexed** β€” January = 0, December = 11. [S1] - **Date objects are static** β€” the computer time is ticking, but the date object, once created, is not. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Now** β€” `new Date()` for current date/time. [S1] - **From components** β€” `new Date(year, month, day, ...)`, remembering month is 0-based. [S1] - **From epoch ms** β€” `new Date(ms)`; `new Date(0)` is the 1970 epoch. [S1] - **Display conversions** β€” `toString`, `toDateString`, `toUTCString`, `toISOString`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Creating Date Objects** β€” Date objects are created with the `new Date()` constructor. There are 4 ways to create a new date object: with no arguments, with a date string, with date arguments (numbers), or with milliseconds. [S1] **new Date()** β€” creates a date object with the current date and time: [S1] ```javascript const d = new Date(); ``` **new Date(date string)** β€” creates a date object from a date string: [S1] ```javascript const d = new Date("October 13, 2014 11:13:00"); ``` ```javascript const d = new Date("2022-03-25"); ``` **new Date(year, month, ...)** β€” creates a date object with a specified date and time. 7 numbers specify year, month, day, hour, minute, second, and millisecond (in that order): [S1] ```javascript const d = new Date(2018, 11, 24, 10, 33, 30, 0); ``` 6 numbers specify year, month, day, hour, minute, second: [S1] ```javascript const d = new Date(2018, 11, 24, 10, 33, 30); ``` 5 numbers specify year, month, day, hour, and minute: [S1] ```javascript const d = new Date(2018, 11, 24, 10, 33); ``` 4 numbers specify year, month, day, and hour: [S1] ```javascript const d = new Date(2018, 11, 24, 10); ``` 3 numbers specify year, month, and day: [S1] ```javascript const d = new Date(2018, 11, 24); ``` 2 numbers specify year and month: [S1] ```javascript const d = new Date(2018, 11); ``` > Note: JavaScript counts months from 0 to 11: January = 0. December = 11. [S1] **new Date(milliseconds)** β€” creates a new date object as zero time plus milliseconds. January 01 1970 plus 100 000 000 000 milliseconds is approximately March 03 1973: [S1] ```javascript const d = new Date(100000000000); ``` Negative milliseconds go before 1970: [S1] ```javascript const d = new Date(-100000000000); ``` One day (24 hours) in milliseconds: [S1] ```javascript const d = new Date(24 * 60 * 60 * 1000); // or const d = new Date(86400000); ``` Zero time is January 01 1970 00:00:00 UTC: [S1] ```javascript const d = new Date(0); ``` **Displaying Dates** β€” JavaScript will (by default) output dates using the `toString()` method, a string representation of the date including the time zone. Other conversions: [S1] ```javascript const d = new Date(); d.toString(); ``` ```javascript const d = new Date(); d.toDateString(); ``` ```javascript const d = new Date(); d.toUTCString(); ``` ```javascript const d = new Date(); d.toISOString(); ``` ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own snippets are the canonical applied examples β€” creating "now", a date from a string, a date from 2–7 numeric components, dates from milliseconds (including `new Date(0)`), and converting to string formats. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Current date / from components / from epoch: ```javascript const now = new Date(); const dec24 = new Date(2018, 11, 24, 10, 33, 30); // month 11 = December const epoch = new Date(0); // Jan 01 1970 UTC ``` Display conversions: ```javascript const d = new Date(); d.toDateString(); d.toUTCString(); d.toISOString(); ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. The source emphasizes the zero-based month convention (January = 0) as a common point of confusion. [S1] ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.89 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[JavaScript Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[JavaScript Date Formats]], [[JavaScript Date Methods]], [[JavaScript Numbers]] - **μ°Έμ‘° λ§₯락:** Referenced whenever date/time values must be created or displayed. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript Dates β€” https://www.w3schools.com/js/js_dates.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Dates" page (Astra wiki-curation, P-Reinforce v3.1 format).