9609c04755
W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더). - Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외) - Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체) - Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속) 각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
159 lines
5.9 KiB
Markdown
159 lines
5.9 KiB
Markdown
---
|
||
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).
|