Input DatetimeLocal max Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime Local


The max property sets or gets the max attribute of a local datetime field, which controls the maximum date and time for a local datetime field.

Set the max property with the following Values

Value Description Sets the maximum date and time allowed for the local datetime field.
  • YYYY - year (e.g. 2011)
  • MM - month (e.g. 01 for January)
  • DD - day of the month (e.g. 08)
  • T - a required separator if time is also specified
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minutes (e.g. 55)
  • ss - seconds (e.g. 03)
  • ms - milliseconds (e.g. 510)

Return Value

A String, representing the maximum date and time allowed

The following code shows how to get the maximum date and time allowed for a local datetime field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

Date and time:// w  w w  .j a va2  s.c  om
<input type="datetime-local" id="myLocalDate" min="2000-10-06T22:22:55" max="2018-11-16T21:25:33">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myLocalDate").max;
    document.getElementById("demo").innerHTML = x;

Related Tutorials