Files
2nd/10_Wiki/Topic_JavaScript/JavaScript_Date_Get.md
T
koriweb 9609c04755 docs(10_Wiki): W3Schools 위키화 — HTML/CSS/JavaScript(core)
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>
2026-06-23 19:21:18 +09:00

8.1 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
javascript-date-get-methods JavaScript Date Get Methods Frontend draft conceptual
Date getters
getFullYear
getMonth
getDate
getTime
Date.now
getTimezoneOffset
B 0.9 2026-06-23 2026-06-23
javascript
js
web
frontend
w3schools
date
getter
https://www.w3schools.com/js/js_date_methods.asp

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-basedgetMonth() returns 0-11, where January is 0. [S1]
  • Weekdays are zero-basedgetDay() 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]

const date = new Date();

getFullYear() — year as a four digit number (yyyy) [S1]

const d = new Date("2021-03-25");
d.getFullYear();
const d = new Date();
d.getFullYear();

getMonth() — month as a number (0-11) [S1]

const d = new Date("2021-03-25");
d.getMonth();
const d = new Date();
d.getMonth();

You can use an array of names to return the month as a name: [S1]

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()];
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]

const d = new Date("2021-03-25");
d.getDate();
const d = new Date();
d.getDate();

getHours() — hour (0-23) [S1]

const d = new Date("2021-03-25");
d.getHours();
const d = new Date();
d.getHours();

getMinutes() — minute (0-59) [S1]

const d = new Date("2021-03-25");
d.getMinutes();
const d = new Date();
d.getMinutes();

getSeconds() — second (0-59) [S1]

const d = new Date("2021-03-25");
d.getSeconds();
const d = new Date();
d.getSeconds();

getMilliseconds() — millisecond (0-999) [S1]

const d = new Date("2021-03-25");
d.getMilliseconds();
const d = new Date();
d.getMilliseconds();

getDay() — weekday as a number (0-6) [S1]

const d = new Date("2021-03-25");
d.getDay();
const d = new Date();
d.getDay();

You can use an array of names to return the weekday as a name: [S1]

const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

const d = new Date("2021-03-25");
let day = days[d.getDay()];
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]

const d = new Date("1970-01-01");
d.getTime();
const d = new Date("2021-03-25");
d.getTime();
const d = new Date();
d.getTime();

Date.now() — current milliseconds since January 1, 1970 [S1]

let ms = Date.now();

Calculate the number of years since 1970: [S1]

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]

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):

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:

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)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Date Get Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).