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

HTML DOM Time dateTime property

Time dateTime property

Time Object Reference The Time object

Example

Obtain the

var x = document.getElementById("myTime").dateTime;

x The output is:

2014-02-14

Try it »


Definition and Usage

The dateTime property sets or returns

the datetime property specifies a date or time. This property is used when no date or time is specified in the content of the element.

**Note:** The datetime property does not render any special effect in all browsers.

Note:


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Only Firefox and Opera 12 support the dateTime property.

**Note:** Starting from version 15, Opera no longer supports this property.


Syntax

Return the dateTime property:

timeObject

.dateTime

Set the dateTime property:

timeObject

.dateTime=

YYYY-MM-DDThh:mm:ssTZD

Attribute values

Value Description
YYYY-MM-DDThh:mm:ssTZD Date or time. The components are explained below:
  • YYYY - year (e.g. 2011)
  • MM - month (e.g. 01 for January)
  • DD - day of the month (e.g. 08)
  • T - Required separator if the time is specified
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minute (e.g. 55)
  • ss - second (e.g. 03)
  • TZD - time zone identifier (Z for Zulu, also known as Greenwich Mean Time)
  • |

    Technical Details

    Return Value: String, representing the computer-processable form of the date and time of the element.

    More examples

    Example

    changing

    document.getElementById("myTime").dateTime="1999-06-24T09:30Z";

    Try it »

    Related Articles

    HTML Reference Manual:HTML


    Time Object Reference The Time object