Easy Tutorial
❮ Prop Html Id Prop Number Form ❯

Input Datetime value Attribute

Input Datetime Object

Example

Set the date and time for the datetime field:

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

Definition and Usage

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

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


Browser Support

All major browsers support the value attribute.

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


Syntax

Return the value attribute:

Set the value attribute:

Attribute Values

Value Description
YYYY-MM-DDThh:mm:ssTZD Describes the date and time. Breakdown as follows: YYYY - Year (e.g., 2011)<br> MM - Month (e.g., 01 for January)<br> DD - Day (e.g., 08)<br> T - Separator required if time is specified<br> hh - Hour (e.g., 22 for 10.00pm)<br> mm - Minute (e.g., 55)<br> ss - Second (e.g., 03)<br> TZD - Time zone indicator (Z stands for Zulu, also known as Greenwich Mean Time)

Technical Details

| Return Value: | 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;
2014-02-06T10:57Z

Related Pages

HTML Reference: HTML <input> value Attribute


❮ Prop Html Id Prop Number Form ❯