HTML/Elements/input/datetime

From Web Education Community Group
< HTML‎ | Elements‎ | input
Revision as of 14:30, 12 March 2012 by Hiroki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<input type="datetime">

The date and time state represents a control for setting the element's value to a string representing a specific global date and time.

Point

  • User agents may display the date and time in whatever time zone is appropriate for the user.


  • The value attribute, if specified, must have a value that is a valid global date and time string.


HTML Attributes

  • autocomplete = on/ off/ defult
    • on
      The on state indicates that the value is not particularly sensitive and the user can expect to be able to rely on his user agent to remember values he has entered for that control.
    • off
      The off state indicates either that the control's input data is particularly sensitive (for example the activation code for a nuclear weapon); or that it is a value that will never be reused (for example a one-time-key for a bank login) and the user will therefore have to explicitly enter the data each time, instead of being able to rely on the UA to prefill the value for him; or that the document provides its own autocomplete mechanism and does not want the user agent to provide autocompletion values.
    • defult
      The default state indicates that the user agent is to use the autocomplete attribute on the element's form owner instead. (By default, the autocomplete attribute of form elements is in the on state.)


  • list = ID reference
    Identify an element that lists predefined options suggested to the user.
    If present, its value must be the ID of a datalist element in the same document.


  • max = valid global date and time string
    indicate the allowed range of values for the element.


  • min = valid global date and time string
    indicate the allowed range of values for the element.


  • name = string
    Gives the name of the input element.


  • readonly = boolean
    Controls whether or not the user can edit the form control.


  • required = boolean
    When specified, the element is required.


  • step = any/ positive floating-point number
    Specifies the value granularity of the element’s value.


  • value = string
    Gives the default value of the input element.


Examples

Example A

The following fragment shows part of a calendar application. A user can specify a date and time for a meeting (in his local time zone, probably, though the user agent can allow the user to change that), and since the submitted data includes the time-zone offset, the application can ensure that the meeting is shown at the correct time regardless of the time zones used by all the participants.[try it]:

<fieldset>
  <legend>Add Meeting</legend>
  <p><label>Meeting name: <input type=text name="meeting.label"></label>
  <p><label>Meeting time: <input type=datetime name="meeting.start"></label>
</fieldset>


HTML Reference

The HTML5 specification defines the Datetime state in 4.10.7.1.7 DATE AND TIME STATE.