[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Date [Back]  [Original]

Date - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Date

Baseline Widely available *

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

* Some parts of this feature may have varying levels of support.

JavaScript Date . Date 1970 1 1 UTC( ) .

: TC39 / API Temporal . Igalia . !

In this article

ECMAScript

JavaScript 1970 1 1 UTC , UNIX (UNIX epoch, 1970 1 1 ) .

: Date UTC , ( ) .

Date JavaScript . (Number.MAX_SAFE_INTEGER 9,007,199,254,740,991.) , ECMA-262 1970 1 1 UTC 100,000,000(1) Date . 271821 4 20 275760 9 13 , 8,640,000,000,000,000 .

, (UTC) . (UTC , .) .

getDay() setHours() getUTCDay() setUTCHours() UTC / .

Date()

new Date().toString() .

new Date()

Date .

Date.now()

1970 1 1 00:00:00 UTC . .

Date.parse()

, 1970 1 1 00:00:00 UTC .

: Date.parse() .

Date.UTC()

( , 2 ~ 7) , 1970 1 1 00:00:00 UTC . .

Date.prototype.getDate()

Date (131) .

Date.prototype.getDay()

Date (06) .

Date.prototype.getFullYear()

Date ( ) .

Date.prototype.getHours()

Date (023) .

Date.prototype.getMilliseconds()

Date (0999) .

Date.prototype.getMinutes()

Date (059) .

Date.prototype.getMonth()

Date (011) .

Date.prototype.getSeconds()

Date (059) .

Date.prototype.getTime()

1970 1 1 00:00:00 UTC . Date .

Date.prototype.getTimezoneOffset()

UTC .

Date.prototype.getUTCDate()

Date (131) .

Date.prototype.getUTCDay()

Date (06) .

Date.prototype.getUTCFullYear()

Date ( ) .

Date.prototype.getUTCHours()

Date (023) .

Date.prototype.getUTCMilliseconds()

Date (0999) .

Date.prototype.getUTCMinutes()

Date (059) .

Date.prototype.getUTCMonth()

Date (011) .

Date.prototype.getUTCSeconds()

Date (059) .

Date.prototype.setDate()

.

Date.prototype.setFullYear()

( ) .

Date.prototype.setHours()

.

Date.prototype.setMilliseconds()

.

Date.prototype.setMinutes()

.

Date.prototype.setMonth()

.

Date.prototype.setSeconds()

.

Date.prototype.setTime()

Date 1970 1 1 00:00:00 UTC () . .

Date.prototype.setUTCDate()

.

Date.prototype.setUTCFullYear()

( ) .

Date.prototype.setUTCHours()

.

Date.prototype.setUTCMilliseconds()

.

Date.prototype.setUTCMinutes()

.

Date.prototype.setUTCMonth()

.

Date.prototype.setUTCSeconds()

.

Date.prototype.toDateString()

Date , .

Date.prototype.toISOString()

Date ISO 8601 .

Date.prototype.toJSON()

toISOString() Date . JSON.stringify() .

Date.prototype.toLocaleDateString()

Date .

Date.prototype.toLocaleFormat()

Date .

Date.prototype.toLocaleString()

Date . Object.prototype.toLocaleString() .

Date.prototype.toLocaleTimeString()

Date .

Date.prototype.toString()

Date . Object.prototype.toString() .

Date.prototype.toTimeString()

Date , .

Date.prototype.toUTCString()

Date UTC .

Date.prototype.valueOf()

Date . Object.prototype.valueOf() .

Date

JavaScript .

: Date ( Date.parse()) .

js
let today = new Date();
let birthday = new Date("December 17, 1995 03:24:00");
let birthday = new Date("1995-12-17T03:24:00");
let birthday = new Date(1995, 11, 17); //  0 
let birthday = new Date(1995, 11, 17, 3, 24, 0);

1900

Date 0 99 1900 1999 . .

1900 , 0 ~ 99 Date.prototype.setFullYear() Date.prototype.getFullYear() .

js
let date = new Date(98, 1); // Sun Feb 01 1998 00:00:00 GMT+0900 ( )

//  :  98 1998 
date.setYear(98); // Sun Feb 01 1998 00:00:00 GMT+0900 ( )

date.setFullYear(98); // Sat Feb 01 0098 00:00:00 GMT+0827 ( )

JavaScript .

, , () , // .

js
// Date  
let start = Date.now();

//     
doSomethingForALongTime();
let end = Date.now();
let elapsed = end - start; //   
js
//   
let start = new Date();

//     
doSomethingForALongTime();
let end = new Date();
let elapsed = end.getTime() - start.getTime(); //   
js
//   ,    
function printElapsedTime(fTest) {
  let nStartTime = Date.now(),
    vReturn = fTest(),
    nEndTime = Date.now();

  console.log(`Elapsed time: ${String(nEndTime - nStartTime)} milliseconds`);
  return vReturn;
}

let yourFunctionReturn = printElapsedTime(yourFunction);

ECMAScript

js
let seconds = Math.floor(Date.now() / 1000);

, . "" Math.round() Math.floor() .

Specification
ECMAScript 2027 LanguageSpecification
# sec-date-objects


Web Proxy Viewer  |  New URL  |  Original Page