aboutsummaryrefslogtreecommitdiff
path: root/files/vi/web/javascript/reference/global_objects/date
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
commit218934fa2ed1c702a6d3923d2aa2cc6b43c48684 (patch)
treea9ef8ac1e1b8fe4207b6d64d3841bfb8990b6fd0 /files/vi/web/javascript/reference/global_objects/date
parent074785cea106179cb3305637055ab0a009ca74f2 (diff)
downloadtranslated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.gz
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.bz2
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.zip
initial commit
Diffstat (limited to 'files/vi/web/javascript/reference/global_objects/date')
-rw-r--r--files/vi/web/javascript/reference/global_objects/date/index.html260
-rw-r--r--files/vi/web/javascript/reference/global_objects/date/parse/index.html202
2 files changed, 462 insertions, 0 deletions
diff --git a/files/vi/web/javascript/reference/global_objects/date/index.html b/files/vi/web/javascript/reference/global_objects/date/index.html
new file mode 100644
index 0000000000..7e485400e4
--- /dev/null
+++ b/files/vi/web/javascript/reference/global_objects/date/index.html
@@ -0,0 +1,260 @@
+---
+title: Date
+slug: Web/JavaScript/Reference/Global_Objects/Date
+tags:
+ - Date
+ - JavaScript
+ - Vietnamese
+translation_of: Web/JavaScript/Reference/Global_Objects/Date
+---
+<div>{{JSRef}}</div>
+
+<p>Tạo ra một thể hiện JavaScript <strong>Date</strong> đại diện cho một khoảnh khắc trong thời gian. Đối tượng ngày được dựa trên giá trị thời gian là số mili giây kể từ ngày 1 tháng 1 năm 1970 UTC.</p>
+
+<h2 id="Cú_pháp">Cú pháp</h2>
+
+<pre class="syntaxbox">new Date();
+new Date(<var>value</var>);
+new Date(<var>dateString</var>);
+new Date(<var>year</var>, <var>month</var>[, <var>date</var>[, <var>hours</var>[, <var>minutes</var>[, <var>seconds</var>[, <var>milliseconds</var>]]]]]);
+</pre>
+
+<div class="note">
+<p><strong>Lưu ý:</strong> Đối tượng JavaScript Date chỉ có thể được khởi tạo bằng cách gọi JavaScript Date như một constructor: gọi nó như là một hàm thông thường (tức là không có toán tử {{jsxref ("Operators / new", "new")}}) sẽ trả về một chuỗi thay vì một tượng Date; không giống như các kiểu đối tượng JavaScript khác, đối tượng JavaScript Date không có cú pháp rút gọn.</p>
+</div>
+
+<h3 id="Các_tham_số">Các tham số</h3>
+
+<div class="note">
+<p><strong>Chú ý:</strong> Trường hợp Date được gọi như một hàm khởi tạo với nhiều hơn một đối số, nếu các giá trị lớn hơn phạm vi hợp lý của chúng (ví dụ: 13 được cung cấp như là giá trị tháng hoặc 70 cho giá trị phút) thì giá trị liền kề sẽ được điều chỉnh. Ví dụ, <code>new Date(2013, 13, 1)</code> tương đương với <code>new Date(2014, 1, 1)</code>, cả hai đều tạo ra một ngày cho <code>2014-02-01</code> (lưu ý rằng tháng này là 0). Tương tự cho các giá trị khác: <code>new Date(2013, 2, 1, 0, 70)</code> tương đương với <code>new Date(2013, 2, 1, 1, 10)</code> mà cả hai đều tạo ra một ngày cho <code>2013-03-01T01:10:00</code>.</p>
+</div>
+
+<div class="note">
+<p><strong>Chú ý:</strong> Trường hợp Date được gọi như một hàm khởi tạo với nhiều hơn một đối số, các đối số xác định đại diện cho thời gian địa phương. Nếu UTC là mong muốn, sử dụng Date mới ({{jsxref ("Date.UTC ()", "Date.UTC (...)")}}) với cùng một đối số.</p>
+</div>
+
+<dl>
+ <dt><code>value</code></dt>
+ <dd>Giá trị số nguyên đại diện cho số mili giây kể từ 01/01/1970-00:00:00 UTC.</dd>
+ <dt><code>dateString</code></dt>
+ <dd>Giá trị chuỗi đại diện cho một ngày. Chuỗi phải ở định dạng được công nhận bới phương thức {{jsxref("Date.parse()")}}.
+ <div class="note">
+ <p><strong>Lưu ý:</strong> Việc phân tách chuỗi ngày với constructor <code>Date</code> (và <code>Date.parse</code>, chúng là tương đương) đôi khi không như mong muốn do sự khác biệt và sự không nhất quán của trình duyệt. Hỗ trợ cho các chuỗi định dạng RFC 2822 chỉ là theo quy ước. Hỗ trợ các định dạng ISO 8601 khác với chuỗi "chỉ có ngày" (ví dụ: "1970-01-01") được coi như là UTC chứ không phải địa phương.</p>
+ </div>
+ </dd>
+ <dt><code>year</code></dt>
+ <dd>Giá trị số nguyên đại diện cho năm. Các giá trị từ 0 đến 99 ứng với các năm từ 1900 đến 1999.</dd>
+ <dt><code>month</code></dt>
+ <dd>Giá trị số nguyên đại diện cho tháng, bắt đầu với 0 cho Tháng Một đến 11 cho Tháng Mười Hai.</dd>
+ <dt><code>date</code></dt>
+ <dd>Tùy chọn. Giá trị số nguyên đại diện cho ngày trong tháng.</dd>
+ <dt><code>hours</code></dt>
+ <dd>Tùy chọn. Giá trị số nguyên đại diện cho giờ trong ngày.</dd>
+ <dt><code>minutes</code></dt>
+ <dd>Tùy chọn. Giá trị số nguyên đại diện cho phần phút của một thời gian.</dd>
+ <dt><code>seconds</code></dt>
+ <dd>Tùy chọn. Giá trị số nguyên đại diện cho phần giây của một thời gian.</dd>
+ <dt><code>milliseconds</code></dt>
+ <dd>Tùy chọn. Giá trị số nguyên đại diện cho phần mili giây của một thời gian.</dd>
+</dl>
+
+<h2 id="Mô_tả">Mô tả</h2>
+
+<ul>
+ <li>Nếu không có các đối số được cung cấp, các hàm khởi tạo tạo đối tượng JavaScript <code>Date</code> với ngày và giờ hiện tại theo các cài đặt hệ thống.</li>
+ <li>Nếu có ít nhất hai đối số được cung cấp, thiếu các đối số được đặt thành 1 (nếu thiếu ngày) hoặc 0 cho tất cả các đối số khác.</li>
+ <li>Ngày JavaScript được dựa trên giá trị thời gian là mili giây kể từ nửa đêm 01 tháng 1 năm 1970 UTC. Một ngày giữ 86.400.000 mili giây. Phạm vi đối tượng JavaScript <code>Date</code> là -100.000.000 ngày đến 100.000.000 ngày liên quan đến ngày 01 tháng 1 năm 1970 UTC.</li>
+ <li>Đối tượng JavaScript Date cung cấp hành vi thống nhất giữa các nền tảng. Giá trị thời gian có thể được truyền giữa các hệ thống để tạo ra một ngày đại diện cho cùng một thời điểm trong thời gian.</li>
+ <li>Đối tượng JavaScript <code>Date</code> hỗ trợ một số phương pháp UTC (phổ quát), cũng như các phương pháp thời gian địa phương. UTC, còn được gọi là <em>Greenwich Mean Time</em> (GMT), nghĩa là thời gian theo World Time Standard (Tiêu chuẩn Thời gian Thế giới). Thời gian địa phương là thời gian được biết đến với máy tính nơi thực hiện lệnh JavaScript.</li>
+ <li>Gọi JavaScript <code>Date</code> như một hàm (nghĩa là không có toán tử {{jsxref("Operators/new", "new")}}) sẽ trả về một chuỗi đại diện cho ngày và giờ hiện tại.</li>
+</ul>
+
+<h2 id="Các_thuộc_tính">Các thuộc tính</h2>
+
+<dl>
+ <dt>{{jsxref("Date.prototype")}}</dt>
+ <dd>Cho phép thêm thuộc tính vào một đối tượng JavaScript <code>Date</code>.</dd>
+ <dt><code>Date.length</code></dt>
+ <dd>Giá trị của <code>Date.length</code> là 7. Đây là số lượng các đối số được xử lý bởi hàm khởi tạo.</dd>
+</dl>
+
+<h2 id="Các_phương_thức">Các phương thức</h2>
+
+<dl>
+ <dt>{{jsxref("Date.now()")}}</dt>
+ <dd>Trả về giá trị số tương ứng với thời gian hiện tại - số mili giây trôi qua kể từ ngày 1 tháng 1 năm 1970, 00:00:00, giờ UTC, với giây phút nhuận được bỏ qua.</dd>
+ <dt>{{jsxref("Date.parse()")}}</dt>
+ <dd>Phân tích cú pháp của một chuỗi đại diện ngày tháng và trả về số mili giây kể từ ngày 1 tháng 1 năm 1970, 00:00:00, giờ UTC, với giây phút nhuận được bỏ qua.
+ <div class="note">
+ <p><strong>Note:</strong> Việc phân tách cú pháp với Date.parse rất không chính xác do sự khác biệt giữa trình duyệt và sự không nhất quán..</p>
+ </div>
+ </dd>
+ <dt>{{jsxref("Date.UTC()")}}</dt>
+ <dd>Chấp nhận các tham số giống với dạng dài nhất của hàm khởi tạo (tức là 2 đến 7) và trả về số mili giây kể từ ngày 1 tháng 1 năm 1970, 00:00:00 giờ UTC, với giây phút nhuận được bỏ qua.</dd>
+</dl>
+
+<h2 id="Thể_hiện_của_JavaScript_Date">Thể hiện của JavaScript <code>Date</code></h2>
+
+<p>Tất cả thể hiện của <code>Date</code> kế thừa từ {{jsxref("Date.prototype")}}. Đối tượng nguyên mẫu của hàm khởi tạo <code>Date</code> có thể được sửa đổi để ảnh hưởng đến tất cả thể hiện của <code>Date</code>.</p>
+
+<h3 id="Date.prototype_Methods">Date.prototype Methods</h3>
+
+<div>{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype', 'Methods')}}</div>
+
+<h2 id="Các_ví_dụ">Các ví dụ</h2>
+
+<h3 id="Một_số_cách_để_tạo_một_đối_tượng_Date">Một số cách để tạo một đối tượng <code>Date</code></h3>
+
+<p>Các ví dụ sau đây cho thấy một số cách để tạo các ngày JavaScript:</p>
+
+<div class="note">
+<p><strong>Chú ý:</strong> Việc phân tích các chuỗi ngày với constructor Date (và Date.parse, chúng là tương đương) rất không chính xác do sự khác biệt và sự không nhất quán của trình duyệt.</p>
+</div>
+
+<pre class="brush: js">var today = new Date();
+var birthday = new Date('October 30, 1996 15:27:08');
+var birthday = new Date('1996-10-30T15:27:08');
+var birthday = new Date(1996, 10, 30);
+var birthday = new Date(1996, 10, 30, 15, 27, 8);
+</pre>
+
+<h3 id="Các_năm_hai_số_ứng_với_1900_-_1999">Các năm hai số ứng với 1900 - 1999</h3>
+
+<p>Để tạo và lấy các ngày giữa các năm 0 đến 99 các phương thức {{jsxref("Date.prototype.setFullYear()")}} và {{jsxref("Date.prototype.getFullYear()")}} nên được sử dụng.</p>
+
+<pre class="brush: js">var date = new Date(98, 1); // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT).
+
+// Phương thức bị phản đối, 98 ứng với 1998 ở đây cũng vậy.
+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).
+</pre>
+
+<h3 id="Tính_thời_gian_trôi_qua">Tính thời gian trôi qua</h3>
+
+<p>Các ví dụ sau chỉ ra cách xác định thời gian trôi qua giữa hai ngày JavaScript trong mili giây.</p>
+
+<p>Do những ngày dài khác nhau (do thay đổi ánh sáng ban ngày), tháng và năm, thể hiện thời gian trôi qua theo đơn vị lớn hơn giờ, phút và giây đòi hỏi phải giải quyết một số vấn đề và cần được nghiên cứu kỹ trước khi cố gắng thử.</p>
+
+<pre class="brush: js">// using Date objects
+var start = Date.now();
+
+// the event to time goes here:
+doSomethingForALongTime();
+var end = Date.now();
+var elapsed = end - start; // elapsed time in milliseconds
+</pre>
+
+<pre class="brush: js">// using built-in methods
+var start = new Date();
+
+// the event to time goes here:
+doSomethingForALongTime();
+var end = new Date();
+var elapsed = end.getTime() - start.getTime(); // elapsed time in milliseconds
+</pre>
+
+<pre class="brush: js">// to test a function and get back its return
+function printElapsedTime(fTest) {
+ var nStartTime = Date.now(),
+ vReturn = fTest(),
+ nEndTime = Date.now();
+
+ console.log('Elapsed time: ' + String(nEndTime - nStartTime) + ' milliseconds');
+ return vReturn;
+}
+
+yourFunctionReturn = printElapsedTime(yourFunction);
+</pre>
+
+<div class="note">
+<p><strong>Chú ý:</strong> Trong các trình duyệt hỗ trợ {{domxref("window.performance", "API Hiệu suất Web", "", 1)}} tính năng thời gian có độ phân giải cao, {{domxref("Performance.now()")}} có thể cung cấp các phép đo đáng tin cậy và chính xác về thời gian trôi qua hơn {{jsxref("Date.now()")}}.</p>
+</div>
+
+<h2 id="Thông_số_kỹ_thuật">Thông số kỹ thuật</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Đặc điểm kỹ thuật</th>
+ <th scope="col">Trạng thái</th>
+ <th scope="col">Chú thích</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-date-objects', 'Date')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-date-objects', 'Date')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.9', 'Date')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES1')}}</td>
+ <td>{{Spec2('ES1')}}</td>
+ <td>Định nghĩa ban đầu. Được thực hiện trong JavaScript 1.1.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Khả_năng_tương_thích_trình_duyệt">Khả năng tương thích trình duyệt</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Đặc tính</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Hỗ trợ cơ bản</td>
+ <td>{{CompatVersionUnknown}} [1]</td>
+ <td>{{CompatVersionUnknown}} [1]</td>
+ <td>{{CompatVersionUnknown}} [2]</td>
+ <td>{{CompatVersionUnknown}} [1]</td>
+ <td>{{CompatVersionUnknown}} [1]</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Đặc tính</th>
+ <th>Android</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Hỗ trợ cơ bản</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] Một số trình duyệt có thể gặp sự cố khi phân tích ngày tháng: <a href="http://dygraphs.com/date-formats.html">3/14/2012 blog from danvk Comparing FF/IE/Chrome on Parsing Date Strings</a>.</p>
+
+<p>[2] <a href="https://msdn.microsoft.com/en-us//library/ie/ff743760(v=vs.94).aspx">ISO8601 Date Format is not supported</a> Trong Internet Explorer 8, và các phiên bản khác có thể có <a href="http://dygraphs.com/date-formats.html">vấn đề chuyển đổi ngày tháng</a>.</p>
diff --git a/files/vi/web/javascript/reference/global_objects/date/parse/index.html b/files/vi/web/javascript/reference/global_objects/date/parse/index.html
new file mode 100644
index 0000000000..34b139a8f0
--- /dev/null
+++ b/files/vi/web/javascript/reference/global_objects/date/parse/index.html
@@ -0,0 +1,202 @@
+---
+title: Date.parse()
+slug: Web/JavaScript/Reference/Global_Objects/Date/parse
+translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse
+---
+<div>{{JSRef}}</div>
+
+<p>Phương thức <strong><code>Date.parse()</code></strong> phân tích cú pháp của một chuỗi đại diện của một ngày và trả về số mili giây kể từ 01 tháng 01 năm 1970, 00:00:00 UTC hoặc NaN nếu chuỗi không nhận dạng được hoặc trong một số trường hợp, chứa các giá trị ngày không hợp lệ (ví dụ 2015-02-31).</p>
+
+<p>It is not recommended to use <code>Date.parse</code> as until ES5, parsing of strings was entirely implementation dependent. There are still many differences in how different hosts parse date strings, therefore date strings should be manually parsed (a library can help if many different formats are to be accommodated).</p>
+
+<div>{{EmbedInteractiveExample("pages/js/date-parse.html")}}</div>
+
+
+
+<h2 id="Syntax">Syntax</h2>
+
+<p>Direct call:</p>
+
+<pre class="syntaxbox">Date.parse(<var>dateString</var>)
+</pre>
+
+<p>Implicit call:</p>
+
+<pre class="syntaxbox">new Date(<var>dateString</var>)
+</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>dateString</code></dt>
+ <dd>A string representing <a href="#Date_Time_String_Format"> a simplification of the ISO 8601 calendar date extended format</a> (other formats may be used, but results are implementation-dependent).</dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>A number representing the milliseconds elapsed since January 1, 1970, 00:00:00 UTC and the date obtained by parsing the given string representation of a date. If the argument doesn't represent a valid date, {{jsxref("NaN")}} is returned.</p>
+
+<h2 id="Description">Description</h2>
+
+<p>The <code>parse()</code> method takes a date string (such as <code>"2011-10-10T14:48:00"</code>) and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC. This function is useful for setting date values based on string values, for example in conjunction with the {{jsxref("Date.prototype.setTime()", "setTime()")}} method and the {{jsxref("Global_Objects/Date", "Date")}} object.</p>
+
+<h3 id="Date_Time_String_Format">Date Time String Format</h3>
+
+<p>The standard string representation of a date time string is a simplification of the ISO 8601 calendar date extended format (see <a href="https://tc39.github.io/ecma262/#sec-date-time-string-format">Date Time String Format</a> section in the ECMAScript specification for more details). For example, <code>"2011-10-10"</code> (date-only form), <code>"2011-10-10T14:48:00"</code> (date-time form), or <code>"2011-10-10T14:48:00.000+09:00"</code> (date-time form with milliseconds and time zone) can be passed and will be parsed. When the time zone offset is absent, date-only forms are interpreted as a UTC time and date-time forms are interpreted as local time.</p>
+
+<p>While time zone specifiers are used during date string parsing to interpret the argument, the value returned is always the number of milliseconds between January 1, 1970 00:00:00 UTC and the point in time represented by the argument or <code>NaN</code>.</p>
+
+<p>Because <code>parse()</code> is a static method of {{jsxref("Date")}}, it is called as <code>Date.parse()</code> rather than as a method of a {{jsxref("Date")}} instance.</p>
+
+<h3 id="Fall-back_to_implementation-specific_date_formats">Fall-back to implementation-specific date formats</h3>
+
+<div class="blockIndicator note">
+<p>This section contains implementation-specific behavior that can be inconsistent across implementations.</p>
+</div>
+
+<p>The ECMAScript specification states: If the String does not conform to the standard format the function may fall back to any implementation–specific heuristics or implementation–specific parsing algorithm. Unrecognizable strings or dates containing illegal element values in ISO formatted strings shall cause <code>Date.parse()</code> to return {{jsxref("NaN")}}.</p>
+
+<p>However, invalid values in date strings not recognized as simplified ISO format as defined by ECMA-262 may or may not result in {{jsxref("NaN")}}, depending on the browser and values provided, e.g.:</p>
+
+<pre class="brush: js">// Non-ISO string with invalid date values
+new Date('23/25/2014');
+</pre>
+
+<p>will be treated as a local date of 25 November, 2015 in Firefox 30 and an invalid date in Safari 7. However, if the string is recognized as an ISO format string and it contains invalid values, it will return {{jsxref("NaN")}} in all browsers compliant with ES5 and later:</p>
+
+<pre class="brush: js">// ISO string with invalid values
+new Date('2014-25-23').toISOString();
+// returns "RangeError: invalid date" in all es5 compliant browsers
+</pre>
+
+<p>SpiderMonkey's implementation-specific heuristic can be found in <a href="https://dxr.mozilla.org/mozilla-central/source/js/src/jsdate.cpp?rev=64553c483cd1#889"><code>jsdate.cpp</code></a>. The string <code>"10 06 2014"</code> is an example of a non–conforming ISO format and thus falls back to a custom routine. See also this <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1023155#c6">rough outline</a> on how the parsing works.</p>
+
+<pre class="brush: js">new Date('10 06 2014');
+</pre>
+
+<p>will be treated as a local date of 6 October, 2014 and not 10 June, 2014. Other examples:</p>
+
+<pre class="brush: js">new Date('foo-bar 2014').toString();
+// returns: "Invalid Date"
+
+Date.parse('foo-bar 2014');
+// returns: NaN
+</pre>
+
+<h3 id="Differences_in_assumed_time_zone">Differences in assumed time zone</h3>
+
+<div class="blockIndicator note">
+<p>This section contains implementation-specific behavior that can be inconsistent across implementations.</p>
+</div>
+
+<p>Given a non-standard date string of <code>"March 7, 2014"</code>, <code>parse()</code> assumes a local time zone, but given a simplification of the ISO 8601 calendar date extended format such as <code>"2014-03-07"</code>, it will assume a time zone of UTC (ES5 and ECMAScript 2015). Therefore {{jsxref("Date")}} objects produced using those strings may represent different moments in time depending on the version of ECMAScript supported unless the system is set with a local time zone of UTC. This means that two date strings that appear equivalent may result in two different values depending on the format of the string that is being converted.</p>
+
+<h2 id="Examples">Examples</h2>
+
+<h3 id="Using_Date.parse()">Using <code>Date.parse()</code></h3>
+
+<p>The following calls all return <code>1546300800000</code>.  The first according to ES5 will imply UTC time, and the others are specifying UTC timezone via the ISO date specification (<code>Z</code> and <code>+00:00</code>)</p>
+
+<pre class="brush: js">Date.parse("2019-01-01")
+Date.parse("2019-01-01T00:00:00.000Z")
+Date.parse("2019-01-01T00:00:00.000+00:00")
+</pre>
+
+<p>The following call, which does not specify a time zone will be set to 2019-01-01 at 00:00:00 in the local timezone of the system.</p>
+
+<pre class="brush: js">Date.parse("2019-01-01T00:00:00")
+</pre>
+
+<h3 id="Non-standard_date_strings">Non-standard date strings</h3>
+
+<div class="blockIndicator note">
+<p>This section contains implementation-specific behavior that can be inconsistent across implementations.</p>
+</div>
+
+<p>If <code>IPOdate</code> is an existing {{jsxref("Date")}} object, it can be set to August 9, 1995 (local time) as follows:</p>
+
+<pre class="brush: js">IPOdate.setTime(Date.parse('Aug 9, 1995'));
+</pre>
+
+<p>Some other examples of parsing non–standard date strings:</p>
+
+<pre class="brush: js">Date.parse('Aug 9, 1995');
+</pre>
+
+<p>Returns <code>807937200000</code> in time zone GMT-0300, and other values in other time zones, since the string does not specify a time zone and is not ISO format, therefore the time zone defaults to local.</p>
+
+<pre class="brush: js">Date.parse('Wed, 09 Aug 1995 00:00:00 GMT');
+</pre>
+
+<p>Returns <code>807926400000</code> no matter the local time zone as GMT (UTC) is provided.</p>
+
+<pre class="brush: js">Date.parse('Wed, 09 Aug 1995 00:00:00');
+</pre>
+
+<p>Returns <code>807937200000</code> in time zone GMT-0300, and other values in other time zones, since there is no time zone specifier in the argument and it is not ISO format, so is treated as local.</p>
+
+<pre class="brush: js">Date.parse('Thu, 01 Jan 1970 00:00:00 GMT');
+</pre>
+
+<p>Returns <code>0</code> no matter the local time zone as a time zone GMT (UTC) is provided.</p>
+
+<pre class="brush: js">Date.parse('Thu, 01 Jan 1970 00:00:00');
+</pre>
+
+<p>Returns <code>14400000</code> in time zone GMT-0400, and other values in other time zones, since no time zone is provided and the string is not in ISO format, therefore the local time zone is used.</p>
+
+<pre class="brush: js">Date.parse('Thu, 01 Jan 1970 00:00:00 GMT-0400');
+</pre>
+
+<p>Returns <code>14400000</code> no matter the local time zone as a time zone GMT (UTC) is provided.</p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES1')}}</td>
+ <td>{{Spec2('ES1')}}</td>
+ <td>Initial definition. Implemented in JavaScript 1.0.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.9.4.2', 'Date.parse')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td>Simplified ISO 8601 format added.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-date.parse', 'Date.parse')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-date.parse', 'Date.parse')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</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.parse")}}</p>
+
+<h2 id="Compatibility_notes">Compatibility notes</h2>
+
+<ul>
+ <li>Firefox 49 {{geckoRelease(49)}} changed the parsing of 2-digit years to be aligned with the Google Chrome browser instead of Internet Explorer. Now, 2-digit years that are less than <code>50</code> are parsed as 21st century years. For example, <code>04/16/17</code>, previously parsed as April 16, 1917, will be April 16, 2017 now. To avoid any interoperability issues or ambiguous years, it is recommended to use the ISO 8601 format like "2017-04-16" ({{bug(1265136)}}).</li>
+ <li>Google Chrome will accept a numerical string as a valid <code><em>dateString</em></code> parameter. This means that, for instance, while <code>!!Date.parse("42")</code> evaluates to <code>false</code> in Firefox, it evaluates to <code>true</code> in Google Chrome because "42" is interpreted as January 1st, 2042.</li>
+</ul>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{jsxref("Date.UTC()")}}</li>
+</ul>