aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/javascript/reference/global_objects/date/settime/index.html
blob: 1d8faed12c3659d507909ca1d37f377ae40690c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: Date.prototype.setTime()
slug: Web/JavaScript/Reference/Global_Objects/Date/setTime
tags:
  - Date
  - JavaScript
  - Method
  - Prototype
  - Reference
translation_of: Web/JavaScript/Reference/Global_Objects/Date/setTime
---
<div>{{JSRef("Global_Objects", "Date")}}</div>

<h2 id="Summary">Сводка</h2>
<p>Метод <strong><code>setTime()</code></strong> устанавливает время объекта {{jsxref("Global_Objects/Date", "Date")}} в значение, представляемое количеством миллисекунд, прошедших с 1 января 1970 00:00:00 по UTC.</p>

<h2 id="Syntax">Синтаксис</h2>
<pre class="syntaxbox"><code><var>dateObj</var>.setTime(<var>timeValue</var>)</code></pre>

<h3 id="Parameters">Параметры</h3>
<dl>
 <dt><code>timeValue</code></dt>
 <dd>Целое число, представляющее количеством миллисекунд, прошедших с 1 января 1970 00:00:00 по UTC.</dd>
</dl>

<h2 id="Description">Описание</h2>
<p>Используя метод <code>setTime()</code>, можно присвоить дату и время другому объекту {{jsxref("Global_Objects/Date", "Date")}}.</p>

<h2 id="Examples">Примеры</h2>

<h3 id="Example:_Using_setTime">Пример: использование метода <code>setTime()</code></h3>
<pre class="brush: js">var theBigDay = new Date('July 1, 1999');
var sameAsBigDay = new Date();
sameAsBigDay.setTime(theBigDay.getTime());
</pre>

<h2 id="Specifications">Спецификации</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Спецификация</th>
   <th scope="col">Статус</th>
   <th scope="col">Комментарии</th>
  </tr>
  <tr>
   <td>ECMAScript 1-е издание.</td>
   <td>Стандарт</td>
   <td>Изначальное определение. Реализована в JavaScript 1.0.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.9.5.27', 'Date.prototype.setTime')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-date.prototype.settime', 'Date.prototype.setTime')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Совместимость с браузерами</h2>
<p>{{Compat}}</p>

<h2 id="See_also">Смотрите также</h2>
<ul>
 <li>{{jsxref("Date.prototype.getTime()")}}</li>
 <li>{{jsxref("Date.prototype.setUTCHours()")}}</li>
</ul>