summaryrefslogtreecommitdiff
path: root/devdocs/html/date_and_time_formats.html
blob: bd41b0355e04a32ef95553a9cfd78f9780ac8ae6 (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
<header><h1>Date and time formats used in HTML</h1></header><div class="section-content">
<p>Certain HTML elements use date and/or time values. The formats of the strings that specify these values are described in this article.</p> <p>Elements that use such formats include certain forms of the <a href="element/input"><code>&lt;input&gt;</code></a> element that let the user choose or specify a date, time, or both, as well as the <a href="element/ins"><code>&lt;ins&gt;</code></a> and <a href="element/del"><code>&lt;del&gt;</code></a> elements, whose <a href="element/ins#datetime"><code>datetime</code></a> attribute specifies the date or date and time at which the insertion or deletion of content occurred.</p> <p>For <code>&lt;input&gt;</code>, the values of <a href="element/input#type"><code>type</code></a> that return a <a href="global_attributes#value"><code>value</code></a> which contains a string representing a date and/or time are:</p> <ul> <li><a href="element/input/date"><code>date</code></a></li> <li><a href="element/input/datetime-local"><code>datetime-local</code></a></li> <li><a href="element/input/month"><code>month</code></a></li> <li><a href="element/input/time"><code>time</code></a></li> <li><a href="element/input/week"><code>week</code></a></li> </ul>
</div>
<h2 id="examples">Examples</h2>
<div class="section-content">
<p>Before getting into the intricacies of how date and time strings are written and parsed in HTML, here are some examples that should give you a good idea what the more commonly-used date and time string formats look like.</p> <figure class="table-container"><div class="_table"><table class="standard-table"> <caption>Example HTML date and time strings</caption> <thead> <tr> <th scope="col">String</th> <th colspan="2" scope="col">Date and/or time</th> </tr> </thead> <tbody> <tr> <td><code>2005-06-07</code></td> <td>June 7, 2005</td> <td><a href="date_and_time_formats#date_strings" aria-current="page">[details]</a></td> </tr> <tr> <td><code>08:45</code></td> <td>8:45 AM</td> <td><a href="date_and_time_formats#time_strings" aria-current="page">[details]</a></td> </tr> <tr> <td><code>08:45:25</code></td> <td>8:45 AM and 25 seconds</td> <td><a href="date_and_time_formats#time_strings" aria-current="page">[details]</a></td> </tr> <tr> <td><code>0033-08-04T03:40</code></td> <td>3:40 AM on August 4, 33</td> <td><a href="date_and_time_formats#local_date_and_time_strings" aria-current="page">[details]</a></td> </tr> <tr> <td><code>1977-04-01T14:00:30</code></td> <td>30 seconds after 2:00 PM on April 1, 1977</td> <td><a href="date_and_time_formats#local_date_and_time_strings" aria-current="page">[details]</a></td> </tr> <tr> <td><code>1901-01-01T00:00Z</code></td> <td>Midnight UTC on January 1, 1901</td> <td><a href="date_and_time_formats#global_date_and_time_strings" aria-current="page">[details]</a></td> </tr> <tr> <td><code>1901-01-01T00:00:01-04:00</code></td> <td>1 second past midnight Eastern Standard Time (EST) on January 1, 1901</td> <td><a href="date_and_time_formats#global_date_and_time_strings" aria-current="page">[details]</a></td> </tr> </tbody> </table></div></figure>
</div>
<h2 id="basics">Basics</h2>
<div class="section-content"><p>Before looking at the various formats of date and time related strings used by HTML elements, it is helpful to understand a few fundamental facts about the way they're defined. HTML uses a variation of the <a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> standard for its date and time strings. It's worth reviewing the descriptions of the formats you're using in order to ensure that your strings are in fact compatible with HTML, as the HTML specification includes algorithms for parsing these strings that is actually more precise than ISO 8601, so there can be subtle differences in how date and time strings are expected to look.</p></div>
<h3 id="character_set">Character set</h3>
<div class="section-content"><p>Dates and times in HTML are always strings which use the <a href="https://developer.mozilla.org/en-US/docs/Glossary/ASCII">ASCII</a> character set.</p></div>
<h3 id="year_numbers">Year numbers</h3>
<div class="section-content">
<p>In order to simplify the basic format used for date strings in HTML, the specification requires that all years be given using the modern (or <strong>proleptic</strong>) <a href="https://en.wikipedia.org/wiki/Gregorian_calendar" target="_blank">Gregorian calendar</a>. While user interfaces may allow entry of dates using other calendars, the underlying value always uses the Gregorian calendar.</p> <p>While the Gregorian calendar wasn't created until the year 1582 (replacing the similar Julian calendar), for HTML's purposes, the Gregorian calendar is extended back to the year 1 C.E. Make sure any older dates account for this.</p> <p>For the purposes of HTML dates, years are always at least four digits long; years prior to the year 1000 are padded with leading zeroes ("<code>0</code>"), so the year 72 is written as <code>0072</code>. Years prior to the year 1 C.E. are not supported, so HTML doesn't support years 1 B.C.E. (1 B.C.) or earlier.</p> <p>A year is normally 365 days long, except during <strong><a href="#leap_years">leap years</a></strong>.</p> <h4 id="leap_years">Leap years</h4> <p>A <strong>leap year</strong> is any year which is divisible by 400 <em>or</em> the year is divisible by 4 but not by 100. Although the calendar year is normally 365 days long, it actually takes the planet Earth approximately 365.2422 days to complete a single orbit around the sun. Leap years help to adjust the calendar to keep it synchronized with the actual position of the planet in its orbit. Adding a day to the year every four years essentially makes the average year 365.25 days long, which is close to correct.</p> <p>The adjustments to the algorithm (taking a leap year when the year can be divided by 400, and skipping leap years when the year is divisible by 100) help to bring the average even closer to the correct number of days (365.2425 days). Scientists occasionally add leap seconds to the calendar (seriously) to handle the remaining three ten-thousandths of a day and to compensate for the gradual, naturally occurring slowing of Earth's rotation.</p> <p>While month <code>02</code>, February, normally has 28 days, it has 29 days in leap years.</p>
</div>
<h3 id="months_of_the_year">Months of the year</h3>
<div class="section-content"><p>There are 12 months in the year, numbered 1 through 12. They are always represented by a two-digit ASCII string whose value ranges from <code>01</code> through <code>12</code>. See the table in the section <a href="#days_of_the_month">Days of the month</a> for the month numbers and their corresponding names (and lengths in days).</p></div>
<h3 id="days_of_the_month">Days of the month</h3>
<div class="section-content">
<p>Month numbers 1, 3, 5, 7, 8, 10, and 12 are 31 days long. Months 4, 6, 9, and 11 are 30 days long. Month 2, February, is 28 days long most years, but is 29 days long in leap years. This is detailed in the following table.</p> <figure class="table-container"><div class="_table"><table class="standard-table"> <caption>The months of the year and their lengths in days</caption> <thead> <tr> <th scope="row">Month number</th> <th scope="col">Name (English)</th> <th scope="col">Length in days</th> </tr> </thead> <tbody> <tr> <th scope="row">01</th> <td>January</td> <td>31</td> </tr> <tr> <th scope="row">02</th> <td>February</td> <td>28 (29 in leap years)</td> </tr> <tr> <th scope="row">03</th> <td>March</td> <td>31</td> </tr> <tr> <th scope="row">04</th> <td>April</td> <td>30</td> </tr> <tr> <th scope="row">05</th> <td>May</td> <td>31</td> </tr> <tr> <th scope="row">06</th> <td>June</td> <td>30</td> </tr> <tr> <th scope="row">07</th> <td>July</td> <td>31</td> </tr> <tr> <th scope="row">08</th> <td>August</td> <td>31</td> </tr> <tr> <th scope="row">09</th> <td>September</td> <td>30</td> </tr> <tr> <th scope="row">10</th> <td>October</td> <td>31</td> </tr> <tr> <th scope="row">11</th> <td>November</td> <td>30</td> </tr> <tr> <th scope="row">12</th> <td>December</td> <td>31</td> </tr> </tbody> </table></div></figure>
</div>
<h2 id="week_strings">Week strings</h2>
<div class="section-content">
<p>A week string specifies a week within a particular year. A <strong>valid week string</strong> consists of a valid <a href="#year_numbers">year number</a>, followed by a hyphen character ("<code>-</code>", or U+002D), then the capital letter "<code>W</code>" (U+0057), followed by a two-digit week of the year value.</p> <p>The week of the year is a two-digit string between <code>01</code> and <code>53</code>. Each week begins on Monday and ends on Sunday. That means it's possible for the first few days of January to be considered part of the previous week-year, and for the last few days of December to be considered part of the following week-year. The first week of the year is the week that contains the <em>first Thursday of the year</em>. For example, the first Thursday of 1953 was on January 1, so that week—beginning on Monday, December 29—is considered the first week of the year. Therefore, December 30, 1952 occurs during the week <code>1953-W01</code>.</p> <p>A year has 53 weeks if:</p> <ul> <li>The first day of the calendar year (January 1) is a Thursday <strong>or</strong>
</li> <li>The first day of the year (January 1) is a Wednesday and the year is a <a href="#leap_years">leap year</a>
</li> </ul> <p>All other years have 52 weeks.</p> <figure class="table-container"><div class="_table"><table> <thead> <tr> <th>Week string</th> <th>Week and year (Date range)</th> </tr> </thead> <tbody> <tr> <td><code>2001-W37</code></td> <td>Week 37, 2001 (September 10-16, 2001)</td> </tr> <tr> <td><code>1953-W01</code></td> <td>Week 1, 1953 (December 29, 1952-January 4, 1953)</td> </tr> <tr> <td><code>1948-W53</code></td> <td>Week 53, 1948 (December 27, 1948-January 2, 1949)</td> </tr> <tr> <td><code>1949-W01</code></td> <td>Week 1, 1949 (January 3-9, 1949)</td> </tr> <tr> <td><code>0531-W16</code></td> <td>Week 16, 531 (April 13-19, 531)</td> </tr> <tr> <td><code>0042-W04</code></td> <td>Week 4, 42 (January 21-27, 42)</td> </tr> </tbody> </table></div></figure> <p>Note that both the year and week numbers are padded with leading zeroes, with the year padded to four digits and the week to two.</p>
</div>
<h2 id="month_strings">Month strings</h2>
<div class="section-content">
<p>A month string represents a specific month in time, rather than a generic month of the year. That is, rather than representing "January," an HTML month string represents a month and year paired, like "January 1972."</p> <p>A <strong>valid month string</strong> consists of a valid <a href="#year_numbers">year number</a> (a string of at least four digits), followed by a hyphen character ("<code>-</code>", or U+002D), followed by a two-digit numeric <a href="#months_of_the_year">month number</a>, where <code>01</code> represents January and <code>12</code> represents December.</p> <figure class="table-container"><div class="_table"><table> <thead> <tr> <th>Month string</th> <th>Month and year</th> </tr> </thead> <tbody> <tr> <td><code>17310-09</code></td> <td>September, 17310</td> </tr> <tr> <td><code>2019-01</code></td> <td>January, 2019</td> </tr> <tr> <td><code>1993-11</code></td> <td>November, 1993</td> </tr> <tr> <td><code>0571-04</code></td> <td>April, 571</td> </tr> <tr> <td><code>0001-07</code></td> <td>July, 1 C.E.</td> </tr> </tbody> </table></div></figure> <p>Notice that all years are at least four characters long; years that are fewer than four digits long are padded with leading zeroes.</p>
</div>
<h2 id="date_strings">Date strings</h2>
<div class="section-content">
<p>A valid date string consists of a <a href="#month_strings">month string</a>, followed by a hyphen character ("<code>-</code>", or U+002D), followed by a two-digit <a href="#days_of_the_month">day of the month</a>.</p> <figure class="table-container"><div class="_table"><table> <thead> <tr> <th>Date string</th> <th>Full date</th> </tr> </thead> <tbody> <tr> <td><code>1993-11-01</code></td> <td>November 1, 1993</td> </tr> <tr> <td><code>1066-10-14</code></td> <td>October 14, 1066</td> </tr> <tr> <td><code>0571-04-22</code></td> <td>April 22, 571</td> </tr> <tr> <td><code>0062-02-05</code></td> <td>February 5, 62</td> </tr> </tbody> </table></div></figure>
</div>
<h2 id="time_strings">Time strings</h2>
<div class="section-content">
<p>A time string can specify a time with precision to the minute, second, or to the millisecond. Specifying only the hour or minute isn't permitted. A <strong>valid time string</strong> minimally consists of a two-digit hour followed by a colon ("<code>:</code>", U+003A), then a two-digit minute. The minute may optionally be followed by another colon and a two-digit number of seconds. Milliseconds may be specified, optionally, by adding a decimal point character ("<code>.</code>", U+002E) followed by one, two, or three digits.</p> <p>There are some additional basic rules:</p> <ul> <li>The hour is always specified using the 24-hour clock, with <code>00</code> being midnight and 11 PM being <code>23</code>. No values outside the range <code>00</code> – <code>23</code> are permitted.</li> <li>The minute must be a two-digit number between <code>00</code> and <code>59</code>. No values outside that range are allowed.</li> <li>If the number of seconds is omitted (to specify a time accurate only to the minute), no colon should follow the number of minutes.</li> <li>If specified, the integer portion of the number of seconds must be between <code>00</code> and <code>59</code>. You <em>cannot</em> specify leap seconds by using values like <code>60</code> or <code>61</code>.</li> <li>If the number of seconds is specified and is an integer, it must not be followed by a decimal point.</li> <li>If a fraction of a second is included, it may be from one to three digits long, indicating the number of milliseconds. It follows the decimal point placed after the seconds component of the time string.</li> </ul> <figure class="table-container"><div class="_table"><table> <thead> <tr> <th>Time string</th> <th>Time</th> </tr> </thead> <tbody> <tr> <td><code>00:00:30.75</code></td> <td>12:00:30.75 AM (30.75 seconds after midnight)</td> </tr> <tr> <td><code>12:15</code></td> <td>12:15 PM</td> </tr> <tr> <td><code>13:44:25</code></td> <td>1:44:25 PM (25 seconds after 1:44 PM)</td> </tr> </tbody> </table></div></figure>
</div>
<h2 id="local_date_and_time_strings">Local date and time strings</h2>
<div class="section-content">
<p>A valid <a href="element/input/datetime-local"><code>datetime-local</code></a> string consists of a <code>date</code> string and a <code>time</code> string concatenated together with either the letter "<code>T</code>" or a space character separating them. No information about the time zone is included in the string; the date and time is presumed to be in the user's local time zone.</p> <p>When you set the <a href="element/input#value"><code>value</code></a> of a <code>datetime-local</code> input, the string is <strong>normalized</strong> into a standard form. Normalized <code>datetime</code> strings always use the letter "<code>T</code>" to separate the date and the time, and the time portion of the string is as short as possible. This is done by leaving out the seconds component if its value is <code>:00</code>.</p> <figure class="table-container"><div class="_table"><table class="standard-table"> <caption> Examples of valid <code>datetime-local</code> strings </caption> <thead> <tr> <th scope="col">Date/time string</th> <th scope="col">Normalized date/time string</th> <th scope="col">Actual date and time</th> </tr> </thead> <tbody> <tr> <td><code>1986-01-28T11:38:00.01</code></td> <td><code>1986-01-28T11:38:00.01</code></td> <td>January 28, 1986 at 11:38:00.01 AM</td> </tr> <tr> <td><code>1986-01-28 11:38:00.010</code></td> <td> <p><code>1986-01-28T11:38:00.01</code></p> <p> Note that after normalization, this is the same string as the previous <code>datetime-local</code> string. The space has been replaced with the "<code>T</code>" character and the trailing zero in the fraction of a second has been removed to make the string as short as possible. </p> </td> <td>January 28, 1986 at 11:38:00.01 AM</td> </tr> <tr> <td><code>0170-07-31T22:00:00</code></td> <td> <p><code>0170-07-31T22:00</code></p> <p> Note that the normalized form of this date drops the "<code>:00</code>" indicating the number of seconds to be zero, because the seconds are optional when zero, and the normalized string minimizes the length of the string. </p> </td> <td>July 31, 170 at 10:00 PM</td> </tr> </tbody> </table></div></figure>
</div>
<h2 id="global_date_and_time_strings">Global date and time strings</h2>
<div class="section-content"><p>A global date and time string specifies a date and time as well as the time zone in which it occurs. A <strong>valid global date and time string</strong> is the same format as a <a href="#local_date_and_time_strings">local date and time string</a>, except it has a time zone string appended to the end, following the time.</p></div>
<h3 id="time_zone_offset_string">Time zone offset string</h3>
<div class="section-content">
<p>A time zone offset string specifies the offset in either a positive or a negative number of hours and minutes from the standard time base. There are two standard time bases, which are very close to the same, but not exactly the same:</p> <ul> <li>For dates after the establishment of <a href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time" target="_blank">Coordinated Universal Time</a> (UTC) in the early 1960s, the time base is <code>Z</code> and the offset indicates a particular time zone's offset from the time at the prime meridian at 0º longitude (which passes through the Royal Observatory at Greenwich, England).</li> <li>For dates prior to UTC, the time base is instead expressed in terms of <a href="https://en.wikipedia.org/wiki/UT1" target="_blank">UT1</a>, which is the contemporary Earth solar time at the prime meridian.</li> </ul> <p>The time zone string is appended immediately following the time in the date and time string. You can specify "<code>Z</code>" as the time zone offset string to indicate that the time is specified in UTC. Otherwise, the time zone string is constructed as follows:</p> <ol> <li>A character indicating the sign of the offset: the plus character ("<code>+</code>", or U+002B) for time zones to the east of the prime meridian or the minus character ("<code>-</code>", or U+002D) for time zones to the west of the prime meridian.</li> <li>A two-digit number of hours that the time zone is offset from the prime meridian. This value must be between <code>00</code> and <code>23</code>.</li> <li>An optional colon ("<code>:</code>") character.</li> <li>A two-digit number of minutes past the hour; this value must be between <code>00</code> and <code>59</code>.</li> </ol> <p>While this format allows for time zones between -23:59 and +23:59, the current range of time zone offsets is -12:00 to +14:00, and no time zones are currently offset from the hour by anything other than <code>00</code>, <code>30</code>, or <code>45</code> minutes. This may change at more or less anytime, since countries are free to tamper with their time zones at any time and in any way they wish to do so.</p> <figure class="table-container"><div class="_table"><table class="no-markdown"> <caption>Examples of valid global date and time strings</caption> <thead> <tr> <th scope="col">Global date and time string</th> <th scope="col">Actual global date and time</th> <th scope="col">Date and time at prime meridian</th> </tr> </thead> <tbody> <tr> <td><code>2005-06-07T00:00Z</code></td> <td>June 7, 2005 at midnight UTC</td> <td>June 7, 2005 at midnight</td> </tr> <tr> <td><code>1789-08-22T12:30:00.1-04:00</code></td> <td> August 22, 1789 at a tenth of a second past 12:30 PM Eastern Daylight Time (EDT) </td> <td>August 22, 1789 at a tenth of a second past 4:30 PM</td> </tr> <tr> <td><code>3755-01-01 00:00+10:00</code></td> <td>January 1, 3755 at midnight Australian Eastern Standard Time (AEST)</td> <td>December 31, 3754 at 2:00 PM</td> </tr> </tbody> </table></div></figure>
</div>
<h2 id="date_issues">Date issues</h2>
<div class="section-content"><p>Because of data storage and precision issues, you may want to be aware of a few client-side and server-side issues.</p></div>
<h3 id="the_y2k38_problem_often_server-side">The Y2K38 Problem (often server-side)</h3>
<div class="section-content">
<p>JavaScript uses double precision floating points to store dates, as with all numbers, meaning that JavaScript code will not suffer from the Y2K38 problem unless integer coercion/bit-hacks are used because all JavaScript bit operators use 32-bit signed 2s-complement integers.</p> <p>The problem is with the server side of things: storage of dates greater than 2^31 - 1. To fix this problem, you must store all dates using either unsigned 32-bit integers, signed 64-bit integers, or double-precision floating points on the server. If your server is written in PHP, the fix may be as simple as upgrading to PHP 8 or 7, and upgrading your hardware to x86_64 or IA64. If you are stuck with other hardware, you can try to emulate 64-bit hardware inside a 32-bit virtual machine, but most VMs don't support this kind of virtualization, since stability may suffer, and performance will definitely suffer greatly.</p>
</div>
<h3 id="the_y10k_problem_often_client-side">The Y10k Problem (often client-side)</h3>
<div class="section-content">
<p>In many servers, dates are stored as numbers instead of as strings--numbers of a fixed size and agnostic of format (aside from endianness). After the year 10,000, those numbers will just be a bit bigger than before, so many servers will not see issues with forms submitted after the year 10,000.</p> <p>The problem is with the client side of things: parsing of dates with more than 4 digits in the year.</p> <div class="code-example">
<p class="example-header"><span class="language-name">html</span></p>
<pre data-signature="ryheDknskFjwnqbOw5jYezRQapczgBa+2YgJfV+Kyxg=" data-language="html"><span class="token comment">&lt;!--midnight of January 1st, 10000: the exact time of Y10K--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>datetime-local<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>+010000-01-01T05:00<span class="token punctuation">"</span></span> <span class="token punctuation">/&gt;</span></span>
</pre>
</div> <p>It's that simple. Just prepare your code for any number of digits. Do not only prepare for 5 digits. Here is JavaScript code for programmatically setting the value:</p> <div class="code-example">
<p class="example-header"><span class="language-name">js</span></p>
<pre data-signature="8UiuA9TwV4wQLeX//ZpNb+m8Frn+H0BONdLcmGllxoI=" data-language="js"><span class="token keyword">function</span> <span class="token function">setValue</span><span class="token punctuation">(</span><span class="token parameter">element<span class="token punctuation">,</span> date</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> isoString <span class="token operator">=</span> date<span class="token punctuation">.</span><span class="token function">toISOString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  element<span class="token punctuation">.</span>value <span class="token operator">=</span> isoString<span class="token punctuation">.</span><span class="token function">substring</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> isoString<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"T"</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre>
</div> <p>Why worry about the Y10K problem if it is going to happen many centuries after your death? Exactly because you will already be dead, so the companies using your software will be stuck using your software without any other coder who knows the system well enough to come in and fix it.</p>
</div>
<h2 id="see_also">See also</h2>
<div class="section-content"><ul> <li><a href="element/input"><code>&lt;input&gt;</code></a></li> <li>
<a href="element/ins"><code>&lt;ins&gt;</code></a> and <a href="element/del"><code>&lt;del&gt;</code></a>: see the <code>datetime</code> attribute, which specifies either a date or a local date and time at which the content was inserted or deleted</li> <li><a href="https://www.iso.org/iso-8601-date-and-time-format.html" target="_blank">The ISO 8601 specification</a></li> <li>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates">Numbers and Dates</a> in the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide">JavaScript Guide</a>
</li> <li>The JavaScript <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date"><code>Date</code></a> object</li> <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat"><code>Intl.DateTimeFormat</code></a> object for formatting dates and times for a given locale</li> </ul></div><div class="_attribution">
  <p class="_attribution-p">
    &copy; 2005&ndash;2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>
    <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats</a>
  </p>
</div>