Input Datetime max attribute

Definition and usage

max Sets or returns the value of the max attribute of the date-time field.

The HTML max attribute specifies the maximum value (date and time) for the date-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

Example

Example 1

Get the furthest date and time allowed by the date-time field:

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

Try it yourself

Example 2

Change the furthest date and time:

document.getElementById("myDatetime").max = "2012-01-01T11:57Z";

Try it yourself

Syntax

Return max attribute:

datetimeObject.max

Set max attribute:

datetimeObject.max = YYYY-MM-DDThh:mm:ssTZD

Attribute value

Value Description
YYYY-MM-DDThh:mm:ssTZD

The furthest date and/or time allowed by the specified date-time field.

Component description:

  • YYYY - Year (e.g., 2023)
  • MM - Month (e.g., 02 represents February)
  • DD - Day of the month (e.g., 15)
  • T - If a time is specified, then the separator is required
  • hh - Hours (e.g., 22 represents 10 PM)
  • mm - Minutes (e.g., 55)
  • ss - Seconds (e.g., 06)
  • TZD - Time zone indicator (Z represents Zulu, also known as Greenwich Mean Time)

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"> element does not display any date and time field/calendar in any mainstream browser except Safari.