Input DatetimeLocal max attribute

Definition and Usage

max Attribute sets or returns the value of the max attribute of the local date and time field.

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:Sifat max untuk <input> HTML

Example

Example 1

Get the maximum 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 maximum date and time allowed for the local date and time field.

Component Description:

  • YYYY - Year (e.g., 2023)
  • MM - Month (e.g., 02 indicates February)
  • DD - Day of the month (e.g., 15)
  • T - If time is specified, it is necessary to separate
  • hh - Hours (e.g., 22 indicates 10 PM)
  • mm - Minutes (e.g., 55)
  • ss - Seconds (e.g., 06)
  • ms - Milliseconds (e.g., 520)

Technical Details

Return Value: Nilai string, menunjukkan tarikh dan masa paling lama yang dibenarkan.

Pendukung perekaan

Angka di dalam tabel menunjukkan versi paling awal perekaan yang menyokong sifat ini.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Dukung 10.0 Dukung Dukung Dukung

Perhatian:Elemen <input type="datetime-local"> tidak menunjukkan sebarang medan tarikh dan masa kalender di Firefox.