Input DatetimeLocal max attribute

Definition and usage

max Attribute setting or returning the value of the max attribute of the local date and time field.

The HTML max attribute specifies the maximum value (date and time) for the local date and time field.

Tip:Use the max attribute and min attribute to create a valid value range.

Tip:To set or return the value of the min attribute, use min attribute

See also:

HTML reference manual:HTML <input> max attribute

Instance

Example 1

Get the furthest date and time allowed for the local date and time field:

var x = document.getElementById("myLocalDate").max;

Try it yourself

Example 2

Change the furthest date and time:

document.getElementById("myLocalDate").max = "2023-12-31T23:59:59";

Try it yourself

Syntax

Return max attribute:

datetimelocalObject.max

Set max attribute:

datetimelocalObject.max = YYYY-MM-DDThh:mm:ss.ms

Attribute value

Value Description
YYYY-MM-DDThh:mm:ss.ms

Specify the furthest date and time allowed for the local date and time field.

Component description:

  • YYYY - Year (for example, 2023)
  • MM - Month (for example, 02 indicates February)
  • DD - Day of the month (for example, 15)
  • T - If a time is specified, the separator is required
  • hh - Hours (for example, 22 indicates 10 PM)
  • mm - Minutes (for example, 55)
  • ss - Seconds (for example, 06)
  • ms - Milliseconds (for example, 520)

Technical details

Return value: A string value representing the latest date and time allowed.

Browser support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="datetime-local"> element does not display any date-time field/calendar in Firefox.