Input DatetimeLocal valueProperty

Input DatetimeLocal 对象参考手册Input DatetimeLocal Object

Example

Set the local date and time of the time field:

document.getElementById("myLocalDate").value = "2014-01-02T11:42:13.510";

Try it yourself »

Definition and Usage

The value property is used to set or return the value of the value attribute of the local time field.

The value property describes the local date and time of the time field.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the value property.

Note:Internet Explorer or Firefox do not support the <input type="datetime-local"> element.


Syntax

Return the value property:

datetimelocalObject.value

Set the value property:

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

Property Values

Value Description
YYYY-MM-DDThh:mm:ssTZD Describes the date and time. Parsed as follows:
  • YYYY - year (e.g., 2011)
  • MM - month (e.g., 01 for January)
  • DD - day (e.g., 08)
  • T - separator required if a time is specified
  • hh - hour (e.g., 22 for 10.00pm)
  • mm - minutes (e.g., 55)
  • ss - seconds (e.g., 03)
  • TZD - time zone designator (Z indicates Zulu, also known as Greenwich Mean Time)

Technical Details

Return value: A string representing the date and time of the local time field


More Examples

Example

Get the local date and time of the time field:

var x = document.getElementById("myLocalDate").value;
xThe output is:
2014-11-16T15:25:33

Try it yourself »


Related Pages

HTML Reference Manual:HTML <input> value Attribute


Input DatetimeLocal 对象参考手册Input DatetimeLocal Object Other Extensions