Input Datetime valueProperty

Input Datetime 对象参考手册Input Datetime Object

Example

Set the date and time of the datetime field:

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

Try it yourself »

Definition and Usage

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

The value attribute describes the date and time of the datetime field.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the value property.

Note:Internet Explorer, Firefox, Opera 15 (and later versions), and Chrome support the <input> element with type="datetime".


Syntax

Return the value property:

datetimeObject.value

Set the value property:

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

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 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 means Zulu, also known as Greenwich Mean Time)

Technical Details

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


More Examples

Example

Get the date and time of the datetime field:

var x = document.getElementById("myDatetime").value;
xThe output is:
2014-02-06T10:57Z

Try it yourself »


Related Pages

HTML Reference Manual:HTML <input> value Attribute


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