aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/javascript/reference/global_objects/date/toutcstring/index.html
blob: 077f04aaad2ffa5f26e101446fada4013cb01af3 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---
title: Date.prototype.toUTCString()
slug: Web/JavaScript/Reference/Global_Objects/Date/toUTCString
tags:
  - Date
  - JavaScript
  - Довідка
  - метод
translation_of: Web/JavaScript/Reference/Global_Objects/Date/toUTCString
---
<div>{{JSRef}}</div>

<p>Метод <strong><code>toUTCString()</code></strong> перетворює дату на рядок, використовуючи часовий пояс UTC.</p>

<p>Заснований на <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">rfc7231</a> та змінений згідно з <a href="https://www.ecma-international.org/ecma-262/10.0/index.html#sec-date.prototype.toutcstring">ecma-262 toUTCString</a>, він може мати від'ємні значення у <a href="https://tc39.es/ecma262/#sec-date.prototype.toutcstring">версії 2021</a>.</p>

<div>{{EmbedInteractiveExample("pages/js/date-toutcstring.html","shorter")}}</div>



<h2 id="Синтаксис">Синтаксис</h2>

<pre class="syntaxbox notranslate"><code><var>dateObj</var>.toUTCString()</code></pre>

<h3 id="Повертає">Повертає</h3>

<p>Рядкове представлення наданої дати з використанням часового поясу UTC.</p>

<h2 id="Опис">Опис</h2>

<p>Значення, яке повертає <code>toUTCString()</code>, є рядком у формі <code><var>Www</var>, <var>dd</var> <var>Mmm</var> <var>yyyy</var> <var>hh</var>:<var>mm</var>:<var>ss</var> GMT</code>, де:</p>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Рядок</th>
   <th scope="col">Опис</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td><code><var>Www</var></code></td>
   <td>День тижня у вигляді трьох літер (наприклад, Sun, Mon, ...)</td>
  </tr>
  <tr>
   <td><code><var>dd</var></code></td>
   <td>Двозначний день місяця, з першим нулем, якщо необхідно</td>
  </tr>
  <tr>
   <td><code><var>Mmm</var></code></td>
   <td>Місяць у вигляді трьох літер (наприклад, Jan, Feb, ...)</td>
  </tr>
  <tr>
   <td><code><var>yyyy</var></code></td>
   <td>Рік, чотири або більше цифр, з першими нулями, якщо необхідно</td>
  </tr>
  <tr>
   <td><code><var>hh</var></code></td>
   <td>Години, дві цифри з першим нулем, якщо необхідно</td>
  </tr>
  <tr>
   <td><code><var>mm</var></code></td>
   <td>Хвилини, дві цифри з першим нулем, якщо необхідно</td>
  </tr>
  <tr>
   <td><code><var>ss</var></code></td>
   <td>Секунди, дві цифри з першим нулем, якщо необхідно</td>
  </tr>
 </tbody>
</table>

<p>До появи ECMAScript 2018, формат значення, яке поверталось, залежив від платформи. Найпоширенішим варіантом була дата у форматі RFC-1123, що є трохи оновленою версією дати у форматі RFC-822.</p>

<h2 id="Приклади">Приклади</h2>

<h3 id="Використання_toUTCString">Використання <code>toUTCString()</code></h3>

<pre class="brush: js notranslate">let today = new Date('Wed, 14 Jun 2017 00:00:00 PDT');
let UTCstring = today.toUTCString(); // Wed, 14 Jun 2017 07:00:00 GMT
</pre>

<h2 id="Специфікації">Специфікації</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Специфікація</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-date.prototype.toutcstring', 'Date.prototype.toUTCString')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Сумісність_з_веб-переглядачами">Сумісність з веб-переглядачами</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>

<p>{{Compat("javascript.builtins.Date.toUTCString")}}</p>

<h2 id="Див._також">Див. також</h2>

<ul>
 <li>{{jsxref("Date.prototype.toLocaleString()")}}</li>
 <li>{{jsxref("Date.prototype.toDateString()")}}</li>
 <li>{{jsxref("Date.prototype.toISOString()")}}</li>
</ul>