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

- 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

Baseline Widely available *

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

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

Date JavaScript . Date , (00:00:00 UTC) 1 1970 ( Unix).

In this article

new Date();
new Date(value);
new Date(dateString);
new Date(year, month[, day[, hour[, minute[, second[, millisecond]]]]]);

: Date Date : ( , new) Date; JavaScript, Date .

: Date , , , (, 13 70 ) . , new Date(2013, 13, 1) new Date(2014, 1, 1), 2014-02-01 ( ). : new Date(2013, 2, 1, 0, 70) new Date(2013, 2, 1, 1, 10) 2013-03-01T01:10:00.

: Date , . UTC, new Date(Date.UTC(...)) .

value

, , 1 1970 00:00:00 UTC ( Unix).

dateString

, . , Date.parse() ( IETF RFC 2822 [ , ], ISO8601 [ , ]).

year

, . 0 99 1900 1999. .

month

, , 0 11 .

day

. , .

hour

. , .

minute

. , .

second

. , .

millisecond

. , .

  • , Date , .
  • , - 1 .
  • JavaScript , 1 1970 UTC. 86 400 000 . Date -100 000 000 100 000 000 1 1970 UTC.
  • Date . , , .
  • Date UTC ( ), . UTC, (GMT), , . , JavaScript.
  • Date ( , new) , .

Date.now()

, , 1 1970 00:00:00 UTC.

Date.parse()

1 1970 00:00:00 .

Date.UTC()

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

Date.prototype Date.

Date.prototype.constructor

-, . Date Date.

: Date

JavaScript:

: Date ( Date.parse) .

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

: 1900 - 1999

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

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

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

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

:

, JavaScript:

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

// ,    ,  :
doSomethingForALongTime();
var end = Date.now();
var elapsed = end - start; //    
js
//   
var start = new Date();

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

  console.log(
    " : " + String(nEndTime - nStartTime) + " ",
  );
  return vReturn;
}

yourFunctionReturn = printElapsedTime(yourFunction);

Unix

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

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

Specification
ECMAScript 2027 LanguageSpecification
# sec-date-objects


Web Proxy Viewer  |  New URL  |  Original Page