Input DatetimeLocal min Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime Local

Description

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

You can use the min and max attributes to create a range of legal values.

Set the min property with the following Values

Value Description
YYYY-MM-DDThh:mm:ss.ms Sets the minimum 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 minimum date and time allowed

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Date and time://from w  w  w  .  j a  va2s  .co  m
<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>

<script>
function myFunction() {
    var x = document.getElementById("myLocalDate").min;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

Related Tutorials