diff options
Diffstat (limited to 'files/uk/web/html/element/input/datetime-local/index.html')
-rw-r--r-- | files/uk/web/html/element/input/datetime-local/index.html | 543 |
1 files changed, 543 insertions, 0 deletions
diff --git a/files/uk/web/html/element/input/datetime-local/index.html b/files/uk/web/html/element/input/datetime-local/index.html new file mode 100644 index 0000000000..b8e88ea62e --- /dev/null +++ b/files/uk/web/html/element/input/datetime-local/index.html @@ -0,0 +1,543 @@ +--- +title: <input type="datetime-local"> +slug: Web/HTML/Element/input/datetime-local +translation_of: Web/HTML/Element/input/datetime-local +--- +<div>{{HTMLRef}}</div> + +<p><span class="seoSummary">{{htmlelement("input")}} типу <strong><code>datetime-local</code></strong> створює елемент керування, який дозволяє користувачу легко вводити і дату, і час, включаючи рік, місяць, день і час у годинах і хвилинах. Застосовується часовий пояс користувача.</span> Вигляд елемента змінюється в загальному залежно від браузера; на даний час його підтримка є непостійною, для настільних пристроїв тільки Chrome/Opera й Edge, а для мобільних тільки найновіші браузери мають дієві його розробки. В інших браузерах вони занепали до простих елементів типу <code><a href="/en-US/docs/Web/HTML/Element/input/text"><input type="text"></a></code>.</p> + +<p>Про підтримку секунд нема й мови.</p> + +<div>{{EmbedInteractiveExample("pages/tabbed/input-datetime-local.html", "tabbed-standard")}}</div> + +<p class="hidden">Джерело цього інтерактивного прикладу зберегається в репозиторії GitHub. Якщо хочете зробити внесок у проект інтерактивних прикладів, будь ласка, зробіть клон <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples </a>і відправте нам pull request.</p> + +<div class="note"> +<p><strong>Примітка:</strong> Через обмежену підтримку браузерами формату <code>datetime-local</code>, і відмінності в роботі елементів введення "input", на даний час, можливо, краще було би вживати якийсь фреймворк чи бібліотеку для їх відображення або використовувати ваш власний елемент введення. Іншим підходом може бути вживання окремих елементів <code>date</code> і <code>time</code>, кожен з яких підтримується ширше, ніж <code>datetime-local</code>.</p> +</div> + +<p>Також деякі браузери для введення часу можуть вдаватися тільки до елемента текстового типу, що перевіряє, чи введені символи становлять правильні значення дати/часу перед відправленням їх на сервер, але небажано покладатися на цей підхід, оскільки його поведінку важко передбачити.</p> + +<p>Для тих із вас, хто не користується браузером із підтримкою <code>datetime-local</code>, елементи керування у Chrome/Opera виглядатимуть як на наступному знімку. Клацнувши справа значок стрілочки вниз, ви отримаєте вибирач дати, а час маєте ввести вручну.</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/14949/datetime-local-chrome.png" style="display: block; height: 224px; margin: 0px auto; width: 280px;"></p> + +<p>The Edge <code>datetime-local</code> control looks like the below; clicking the date and the time parts of the value bring up two separate pickers for you, so you can easily set both the date and the time. This is somewhat like having <code>date</code> and <code>time</code> widgets both created for you and merged into one.</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/14953/datetime-local-picker-edge1.png" style="display: block; height: 398px; margin: 0px auto; width: 320px;"></p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/14955/datetime-local-picker-edge2.png" style="display: block; height: 394px; margin: 0px auto; width: 264px;"></p> + +<table class="properties"> + <tbody> + <tr> + <td><strong>{{anch("Value")}}</strong></td> + <td>A {{domxref("DOMString")}} representing a date and time (in the local time zone), or empty.</td> + </tr> + <tr> + <td><strong>Events</strong></td> + <td>{{event("change")}} and {{event("input")}}.</td> + </tr> + <tr> + <td><strong>Supported Common Attributes</strong></td> + <td>{{htmlattrxref("autocomplete", "input")}}, {{htmlattrxref("list", "input")}}, {{htmlattrxref("readonly", "input")}}, and {{htmlattrxref("step", "input")}}.</td> + </tr> + <tr> + <td><strong>IDL attributes</strong></td> + <td><code>list</code>, <code>value</code>, <code>valueAsNumber</code>.</td> + </tr> + <tr> + <td><strong>Methods</strong></td> + <td>{{domxref("HTMLInputElement.select", "select()")}}, {{domxref("HTMLInputElement.stepDown", "stepDown()")}}, {{domxref("HTMLInputElement.stepUp", "stepUp()")}}.</td> + </tr> + </tbody> +</table> + +<h2 id="Value">Value</h2> + +<p>A {{domxref("DOMString")}} representing the value of the date entered into the input. You can set a default value for the input by including a date and time inside the {{htmlattrxref("value", "input")}} attribute, like so:</p> + +<pre class="brush: html"><label for="party">Enter a date and time for your party booking:</label> +<input id="party" type="datetime-local" name="partydate" value="2017-06-01T08:30"></pre> + +<p>{{ EmbedLiveSample('Value', 600, 60) }}</p> + +<p>One thing to note is that the displayed date and time formats differ from the actual <code>value</code>; the displayed date and time are formatted according to the user's locale as reported by their operating system, whereas the date/time <code>value</code> is always formatted <code>yyyy-MM-ddThh:mm</code>. When the above value submitted to the server, for example, it will look like <code>"partydate=2017-06-01T08:30"</code>.</p> + +<div class="note"> +<p><strong>Note:</strong> Also bear in mind that if such data is submitted via HTTP <code><a href="/en-US/docs/Web/HTTP/Methods/GET">GET</a></code>, the colon character will need to be escaped for inclusion in the URL parameters, e.g. <code>partydate=2017-06-01T08%3A30</code>. See {{jsxref("Global_Objects/encodeURI", "encodeURI()")}} for one way to do this.</p> +</div> + +<p>You can also get and set the date value in JavaScript using the {{domxref("HTMLInputElement.value")}} property, for example:</p> + +<pre class="brush: js">var dateControl = document.querySelector('input[type="datetime-local"]'); +dateControl.value = '2017-06-01T08:30';</pre> + +<p>There are several methods provided by JavaScript's {{jsxref("Date")}} that can be used to convert numeric date information into a properly-formatted string, or you can do it manually. For example, the {{jsxref("Date.toISOString()")}} method can be used for this purpose.</p> + +<h2 id="Using_datetime-local_inputs">Using datetime-local inputs</h2> + +<p>Date/time inputs sound convenient at first glance; they provide an easy UI for choosing dates and times, and they normalize the data format sent to the server, regardless of the user's locale. However, there are issues with <code><input type="datetime-local"></code> because of the limited browser support.</p> + +<p>We'll look at basic and more complex uses of <code><input type="datetime-local"></code>, then offer advice on mitigating the browser support issue later on (see {{anch("Handling browser support")}}).</p> + +<h3 id="Basic_uses_of_datetime-local">Basic uses of datetime-local</h3> + +<p>The simplest use of <code><input type="datetime-local"></code> involves a basic <code><input></code> and {{htmlelement("label")}} element combination, as seen below:</p> + +<pre class="brush: html"><form> + <label for="party">Enter a date and time for your party booking:</label> + <input id="party" type="datetime-local" name="partydate"> +</form></pre> + +<p>{{ EmbedLiveSample('Basic_uses_of_datetime-local', 600, 40) }}</p> + +<h3 id="Setting_maximum_and_minimum_dates_and_times">Setting maximum and minimum dates and times</h3> + +<p>You can use the {{htmlattrxref("min", "input")}} and {{htmlattrxref("max", "input")}} attributes to restrict the dates/times that can be chosen by the user. In the following example we are setting a minimum datetime of <code>2017-06-01T08:30</code> and a maximum datetime of <code>2017-06-30T16:30</code>:</p> + +<pre class="brush: html"> <form> + <label for="party">Enter a date and time for your party booking:</label> + <input id="party" type="datetime-local" name="partydate" min="2017-06-01T08:30" max="2017-06-30T16:30"> + </form></pre> + +<p>{{ EmbedLiveSample('Setting_maximum_and_minimum_dates_and_times', 600, 40) }}</p> + +<p>The result here is that:</p> + +<ul> + <li>Only days in June 2017 can be selected — only the "days" part of the date value will be editable, and dates outside June can't be scrolled to in the datepicker widget.</li> + <li>Depending on what browser you are using, you might find that times outside the specified values might not be selectable in the time picker (e.g. Edge), or invalid (see {{anch("Validation")}}) but still available (e.g. Chrome).</li> +</ul> + +<div class="note"> +<p><strong>Note</strong>: You should be able to use the {{htmlattrxref("step", "input")}} attribute to vary the number of days jumped each time the date is incremented (e.g. maybe you only want to make Saturdays selectable). However, this does not seem to work effectively in any implementation at the time of writing.</p> +</div> + +<h3 id="Controlling_input_size">Controlling input size</h3> + +<p><code><input type="datetime-local"></code> doesn't support form control sizing attributes such as {{htmlattrxref("size", "input")}}. You'll have to resort to <a href="/en-US/docs/Web/CSS">CSS</a> for customizing the sizes of these elements.</p> + +<h3 id="Setting_timezones">Setting timezones</h3> + +<p>One thing the <code>datetime-local</code> input type doesn't provide is a way to set the time zone and/or locale of the date/time control. This was available in the <code><a href="/en-US/docs/Web/HTML/Element/input/datetime">datetime</a></code> input type, but this type is now obsolete, having been removed from the spec. The main reasons why this was removed are a lack of implementation in browsers, and concerns over the user interface/experience. It is easier to just have a control (or controls) for setting the date/time and then deal with the locale in a separate control.</p> + +<p>For example, if you are creating a system where the user is likely to already be logged in, with their locale already set, you could provide the timezone in a <code><a href="/en-US/docs/Web/HTML/Element/input/hidden">hidden</a></code> input type. For example:</p> + +<pre class="brush: html"><input type="hidden" id="timezone" name="timezone" value="-08:00"></pre> + +<p>On the other hand, if you were required to allow the user to enter a timezone along with a date/time input, you could provide a means of inputting a timezone, such as a {{htmlelement("select")}} element:</p> + +<pre class="brush: html"><select name="timezone_offset" id="timezone-offset" class="span5"> + <option value="-12:00">(GMT -12:00) Eniwetok, Kwajalein</option> + <option value="-11:00">(GMT -11:00) Midway Island, Samoa</option> + <option value="-10:00">(GMT -10:00) Hawaii</option> + <option value="-09:50">(GMT -9:30) Taiohae</option> + <option value="-09:00">(GMT -9:00) Alaska</option> + <option value="-08:00">(GMT -8:00) Pacific Time (US &amp; Canada)</option> + + ... + +</select></pre> + +<p>In either case, the date/time and time zone values would be submitted to the server as separate data points, and then you'd need to store them appropriately in the database on the server-side.</p> + +<div class="note"> +<p><strong>Note</strong>: The above code snippet is taken from <a href="https://gist.github.com/nodesocket/3919205">All world timezones in an HTML select element</a>.</p> +</div> + +<h2 id="Validation">Validation</h2> + +<p>By default, <code><input type="datetime-local"></code> does not apply any validation to entered values. The UI implementations generally don't let you enter anything that isn't a date/time — which is helpful — but a user might still fill in no value and submit, or enter an invalid date and/or time (e.g. the 32nd of April).</p> + +<p>You can use {{htmlattrxref("min", "input")}} and {{htmlattrxref("max", "input")}} to restrict the available dates (see anch("Setting maximum and minimum dates")), and you can use the {{htmlattrxref("required", "input")}} attribute to make filling in the date/time mandatory. As a result, supporting browsers will display an error if you try to submit a date that is outside the set bounds, or an empty date field.</p> + +<p>Let's look at an example; here we've set minimum and maximum date/time values, and also made the field required:</p> + +<pre class="brush: html"><form> + <div> + <label for="party">Choose your preferred party date and time (required, June 1st 8.30am to June 30th 4.30pm):</label> + <input id="party" type="datetime-local" name="partydate" min="2017-06-01T08:30" max="2017-06-30T16:30" required> + <span class="validity"></span> + </div> + <div> + <input type="submit" value="Book party!"> + </div> +</form></pre> + +<p>If you try to submit the form with an incomplete date (or with a date outside the set bounds), the browser displays an error. Try playing with the example now:</p> + +<p>{{ EmbedLiveSample('Validation', 600, 120) }}</p> + +<p>Here's a screenshot for those of you who aren't using a supporting browser:</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/14957/datetime-local-error.png" style="display: block; height: 100px; margin: 0px auto; width: 558px;"></p> + +<p>Here's the CSS used in the above example. Here we make use of the {{cssxref(":valid")}} and {{cssxref(":invalid")}} CSS properties to style the input based on whether or not the current value is valid. We had to put the icons on a {{htmlelement("span")}} next to the input, not on the input itself, because in Chrome the generated content is placed inside the form control, and can't be styled or shown effectively.</p> + +<pre class="brush: css">div { + margin-bottom: 10px; + display: flex; + align-items: center; +} + +label { + display: inline-block; + width: 300px; +} + +input:invalid+span:after { + content: '✖'; + padding-left: 5px; +} + +input:valid+span:after { + content: '✓'; + padding-left: 5px; +}</pre> + +<div class="warning"> +<p><strong>Important</strong>: HTML form validation is <em>not</em> a substitute for scripts that ensure that the entered data is in the proper format. It's far too easy for someone to make adjustments to the HTML that allow them to bypass the validation, or to remove it entirely. It's also possible for someone to simply bypass your HTML entirely and submit the data directly to your server. If your server-side code fails to validate the data it receives, disaster could strike when improperly-formatted data is submitted (or data which is too large, is of the wrong type, and so forth).</p> +</div> + +<h2 id="Handling_browser_support">Handling browser support</h2> + +<p>As mentioned above, the major problem with using date inputs at the time of writing is browser support — only Chrome/Opera and Edge support it on desktop, and most modern browsers on mobile. As an example, the <code>datetime-local</code> picker on Firefox for Android looks like this:</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/14951/datetime-local-fxa.png" style="display: block; height: 640px; margin: 0px auto; width: 360px;"></p> + +<p>Non-supporting browsers gracefully degrade to a text input, but this creates problems both in terms of consistency of user interface (the presented control will be different), and data handling.</p> + +<p>The second problem is the most serious; as we mentioned earlier, with a <code>datetime-local</code> input, the actual value is always normalized to the format <code>yyyy-mm-ddThh:mm</code>. With a text input on the other hand, by default the browser has no recognition of what format the date should be in, and there are lots of different ways in which people write dates and times, for example:</p> + +<ul> + <li><code>ddmmyyyy</code></li> + <li><code>dd/mm/yyyy</code></li> + <li><code>mm/dd/yyyy</code></li> + <li><code>dd-mm-yyyy</code></li> + <li><code>mm-dd-yyyy</code></li> + <li><code>mm-dd-yyyy hh:mm</code> (12 hour clock)</li> + <li><code>mm-dd-yyyy hh:mm</code> (24 hour clock)</li> + <li>etc.</li> +</ul> + +<p>One way around this is to put a {{htmlattrxref("pattern", "input")}} attribute on your <code>datetime-local</code> input. Even though the <code>datetime-local</code> input doesn't use it, the text input fallback will. For example, try viewing the following demo in a non-supporting browser:</p> + +<pre class="brush: html"><form> + <div> + <label for="party">Choose your preferred party date and time (required, June 1st 8.30am to June 30th 4.30pm):</label> + <input id="party" type="datetime-local" name="partydate" + min="2017-06-01T08:30" max="2017-06-30T16:30" + pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}" required> + <span class="validity"></span> + </div> + <div> + <input type="submit" value="Book party!"> + </div> + <input type="hidden" id="timezone" name="timezone" value="-08:00"> +</form></pre> + +<p>{{ EmbedLiveSample('Handling_browser_support', 600, 100) }}</p> + +<p>If you try submitting it, you'll see that the browser now displays an error message (and highlights the input as invalid) if your entry doesn't match the pattern <code>nnnn-nn-nnTnn:nn</code>, where <code>n</code> is a number from 0 to 9. Of course, this doesn't stop people from entering invalid dates, or incorrectly formatted dates and times.</p> + +<p>And what user is going to understand the pattern they need to enter the time and date in?</p> + +<p>We still have a problem.</p> + +<div class="hidden"> +<pre class="brush: css">div { + margin-bottom: 10px; +} + +input:invalid + span { + position: relative; +} + +input:invalid + span:after { + content: '✖'; + position: absolute; + right: -18px; +} + +input:valid + span { + position: relative; +} + +input:valid + span:after { + content: '✓'; + position: absolute; + right: -18px; +}</pre> +</div> + +<p>The best way to deal with dates in forms in a cross-browser way at the moment is to get the user to enter the day, month, year, and time in separate controls ({{htmlelement("select")}} elements being popular — see below for an implementation), or use JavaScript libraries such as <a href="https://jqueryui.com/datepicker/">jQuery date picker</a>, and the <a href="http://timepicker.co/">jQuery timepicker plugin</a>.</p> + +<h2 id="Examples">Examples</h2> + +<p>In this example we create two sets of UI elements for choosing datetimes — a native <code><input type="datetime-local"></code> picker, and a set of five {{htmlelement("select")}} elements for choosing dates and times in older browsers that don't support the native input.</p> + +<p>{{ EmbedLiveSample('Examples', 600, 140) }}</p> + +<p>The HTML looks like so:</p> + +<pre class="brush: html"><form> + <div class="nativeDateTimePicker"> + <label for="party">Choose a date and time for your party:</label> + <input type="datetime-local" id="party" name="bday"> + <span class="validity"></span> + </div> + <p class="fallbackLabel">Choose a date and time for your party:</p> + <div class="fallbackDateTimePicker"> + <div> + <span> + <label for="day">Day:</label> + <select id="day" name="day"> + </select> + </span> + <span> + <label for="month">Month:</label> + <select id="month" name="month"> + <option selected>January</option> + <option>February</option> + <option>March</option> + <option>April</option> + <option>May</option> + <option>June</option> + <option>July</option> + <option>August</option> + <option>September</option> + <option>October</option> + <option>November</option> + <option>December</option> + </select> + </span> + <span> + <label for="year">Year:</label> + <select id="year" name="year"> + </select> + </span> + </div> + <div> + <span> + <label for="hour">Hour:</label> + <select id="hour" name="hour"> + </select> + </span> + <span> + <label for="minute">Minute:</label> + <select id="minute" name="minute"> + </select> + </span> + </div> + </div> +</form></pre> + +<p>The months are hard-coded (as they are always the same), while the day and year values are dynamically generated depending on the currently selected month and year, and the current year respectively (see the code comments below for detailed explanations of how these functions work.) We also decided to dynamically generate the hours and minutes, as there are so many of them!</p> + +<div class="hidden"> +<pre class="brush: css">div { + margin-bottom: 10px; + position: relative; +} + +input[type="number"] { + width: 100px; +} + +input + span { + padding-right: 30px; +} + +input:invalid+span:after { + position: absolute; + content: '✖'; + padding-left: 5px; +} + +input:valid+span:after { + position: absolute; + content: '✓'; + padding-left: 5px; +}</pre> +</div> + +<p>The other part of the code that may be of interest is the feature detection code — to detect whether the browser supports <code><input type="datetime-local"></code>, we create a new {{htmlelement("input")}} element, set its <code>type</code> to <code>datetime-local</code>, then immediately check what its type is set to. Browsers that don't support <code>datetime-local</code> return <code>text</code>, since that's what <code>datetime-local</code> falls back to. If <code><input type="datetime-local"></code> is not supported, we hide the native picker and show the fallback picker UI ({{htmlelement("select")}}) instead.</p> + +<pre class="brush: js">// define variables +var nativePicker = document.querySelector('.nativeDateTimePicker'); +var fallbackPicker = document.querySelector('.fallbackDateTimePicker'); +var fallbackLabel = document.querySelector('.fallbackLabel'); + +var yearSelect = document.querySelector('#year'); +var monthSelect = document.querySelector('#month'); +var daySelect = document.querySelector('#day'); +var hourSelect = document.querySelector('#hour'); +var minuteSelect = document.querySelector('#minute'); + +// hide fallback initially +fallbackPicker.style.display = 'none'; +fallbackLabel.style.display = 'none'; + +// test whether a new datetime-local input falls back to a text input or not +var test = document.createElement('input'); +test.type = 'datetime-local'; +// if it does, run the code inside the if() {} block +if(test.type === 'text') { + // hide the native picker and show the fallback + nativePicker.style.display = 'none'; + fallbackPicker.style.display = 'block'; + fallbackLabel.style.display = 'block'; + + // populate the days and years dynamically + // (the months are always the same, therefore hardcoded) + populateDays(monthSelect.value); + populateYears(); + populateHours(); + populateMinutes(); +} + +function populateDays(month) { + // delete the current set of <option> elements out of the + // day <select>, ready for the next set to be injected + while(daySelect.firstChild){ + daySelect.removeChild(daySelect.firstChild); + } + + // Create variable to hold new number of days to inject + var dayNum; + + // 31 or 30 days? + if(month === 'January' | month === 'March' | month === 'May' | month === 'July' | month === 'August' | month === 'October' | month === 'December') { + dayNum = 31; + } else if(month === 'April' | month === 'June' | month === 'September' | month === 'November') { + dayNum = 30; + } else { + // If month is February, calculate whether it is a leap year or not + var year = yearSelect.value; + (year - 2016) % 4 === 0 ? dayNum = 29 : dayNum = 28; + } + + // inject the right number of new <option> elements into the day <select> + for(i = 1; i <= dayNum; i++) { + var option = document.createElement('option'); + option.textContent = i; + daySelect.appendChild(option); + } + + // if previous day has already been set, set daySelect's value + // to that day, to avoid the day jumping back to 1 when you + // change the year + if(previousDay) { + daySelect.value = previousDay; + + // If the previous day was set to a high number, say 31, and then + // you chose a month with less total days in it (e.g. February), + // this part of the code ensures that the highest day available + // is selected, rather than showing a blank daySelect + if(daySelect.value === "") { + daySelect.value = previousDay - 1; + } + + if(daySelect.value === "") { + daySelect.value = previousDay - 2; + } + + if(daySelect.value === "") { + daySelect.value = previousDay - 3; + } + } +} + +function populateYears() { + // get this year as a number + var date = new Date(); + var year = date.getFullYear(); + + // Make this year, and the 100 years before it available in the year <select> + for(var i = 0; i <= 100; i++) { + var option = document.createElement('option'); + option.textContent = year-i; + yearSelect.appendChild(option); + } +} + +function populateHours() { + // populate the hours <select> with the 24 hours of the day + for(var i = 0; i <= 23; i++) { + var option = document.createElement('option'); + option.textContent = (i < 10) ? ("0" + i) : i; + hourSelect.appendChild(option); + } +} + +function populateMinutes() { + // populate the minutes <select> with the 60 hours of each minute + for(var i = 0; i <= 59; i++) { + var option = document.createElement('option'); + option.textContent = (i < 10) ? ("0" + i) : i; + minuteSelect.appendChild(option); + } +} + +// when the month or year <select> values are changed, rerun populateDays() +// in case the change affected the number of available days +yearSelect.onchange = function() { + populateDays(monthSelect.value); +} + +monthSelect.onchange = function() { + populateDays(monthSelect.value); +} + +//preserve day selection +var previousDay; + +// update what day has been set to previously +// see end of populateDays() for usage +daySelect.onchange = function() { + previousDay = daySelect.value; +}</pre> + +<div class="note"> +<p><strong>Note</strong>: Remember that some years have 53 weeks in them (see <a href="https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year">Weeks per year</a>)! You'll need to take this into consideration when developing production apps.</p> +</div> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comments</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('HTML WHATWG', 'forms.html#local-date-and-time-state-(type=datetime-local)', '<input type="datetime-local">')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('HTML5 W3C', 'forms.html##local-date-and-time-state-(type=datetime-local)', '<input type="datetime-local">')}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("html.elements.input.input-datetime-local")}}</p> + +<h2 id="See_also">See also</h2> + +<ul> + <li>The generic {{HTMLElement("input")}} element and the interface used to manipulate it, {{domxref("HTMLInputElement")}}</li> + <li><code><a href="/en-US/docs/Web/HTML/Element/input/date"><input type="date"></a></code> and <code><a href="/en-US/docs/Web/HTML/Element/input/time"><input type="time"></a></code></li> + <li><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/The_native_form_widgets#Date_and_time_picker">Date and Time picker tutorial</a></li> +</ul> |