HTMLTimeElement.dateTime

The HTMLTimeElement.dateTime property is a DOMString that reflects the datetime HTML attribute, containing a machine-readable form of the element's date and time value.

The format of the string must follow one of the following HTML microsyntaxes:

Microsyntax Description Examples
Valid month string YYYY-MM 2011-11, 2013-05
Valid date string YYYY-MM-DD 1887-12-01
Valid yearless date string MM-DD 11-12
Valid time string HH:MM
HH:MM:SS
HH:MM:SS.mmm
23:59
12:15:47
12:15:52.998
Valid local date and time string YYYY-MM-DD HH:MM
YYYY-MM-DD HH:MM:SS
YYYY-MM-DD HH:MM:SS.mmm
YYYY-MM-DDTHH:MM
YYYY-MM-DDTHH:MM:SS
YYYY-MM-DDTHH:MM:SS.mmm
2013-12-25 11:12<br>
			1972-07-25 13:43:07<br>
			1941-03-15 07:06:23.678<br>
			2013-12-25T11:12<br>
			1972-07-25T13:43:07<br>
			1941-03-15T07:06:23.678
Valid time-zone offset string Z
+HHMM
+
HH:MM
-HHMM
-
HH:MM
Z<br>
			+0200<br>
			+04:30<br>
			-0300<br>
			-08:00
Valid global date and time string Any combination of a valid local date and time string followed by a valid time-zone offset string
2013-12-25 11:12+0200<br>
			1972-07-25 13:43:07+04:30<br>
			1941-03-15 07:06:23.678Z<br>
			2013-12-25T11:12-08:00
Valid week string YYYY-WWW 2013-W46
Four or more ASCII digits YYYY 2013, 0001
Valid duration string PdDThHmMsS
PdDThHmMs.XS
PdDThHmMs.XXS
PdDThHmMs.XXXS
PThHmMsS
PThHmMs.XS
PThHmMs.XXS
PThHmMs.XXXS
ww dd hh mm ss
P12DT7H12M13S<br>
			P12DT7H12M13.3S<br>
			P12DT7H12M13.45S<br>
			P12DT7H12M13.455S<br>
			PT7H12M13S<br>
			PT7H12M13.2S<br>
			PT7H12M13.56S<br>
			PT7H12M13.999S<br>
			7d 5h 24m 13s

Syntax

JavaScript
dateTimeString = timeElt.dateTime;
timeElt<code>.dateTime = </code><code>dateTimeString</code>

Examples

JavaScript
// Assumes there is <time id="t"> element in the HTML

var t = document.getElementById("t");
t.dateTime = "6w 5h 34m 5s";

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'HTMLTimeElement' in that specification.
Living Standard No change from HTML5.1.
HTML5.1
The definition of 'HTMLTimeElement' in that specification.
Working Draft No change from HTML5.
HTML5
The definition of 'HTMLTimeElement' in that specification.
Recommendation Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support No support 22.0 (22.0) No support 11.50
Removed in 15.0
No support
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support No support 22.0 (22.0) No support ? No support

See also

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/htmltimeelement/datetime

API HTML DOM HTMLTimeElement Property Reference Référence