Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Datetime value property

Input Datetime value property

Input Datetime Object Reference Input Datetime Object

Example

Set the date and time of the datetime field:

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

Try it »


Definition and Usage

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

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


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the value attribute.

Note: Supported by Internet Explorer, Firefox, Opera 15 (and later), or Chrome. element using type="datetime".


Syntax

Return the value attribute:

datetimeObject

.value

Set the value attribute:

datetimeObject

.value=

YYYY-MM-DDThh:mm:ssTZD

Attribute 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 - Minute (e.g. 55)
  • ss - Second (e.g. 03)
  • TZD - Time zone designator (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;

    x

    The output is:

    2014-02-06T10:57Z

    Try it »


    Related pages

    HTML Reference Manual: HTML value attribute


    Input Datetime Object Reference Input Datetime Object