---
title: HTMLTimeElement.dateTime
slug: Web/API/HTMLTimeElement/dateTime
tags:
  - API
  - HTML DOM
  - HTMLTimeElement
  - Property
  - Reference
browser-compat: api.HTMLTimeElement.dateTime
---
{{ APIRef("HTML DOM") }}

The
**`HTMLTimeElement.dateTime`**
property is a {{domxref("DOMString")}} that reflects the {{ htmlattrxref("datetime",
  "time") }} 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:

<table class="no-markdown">
  <thead>
    <tr>
      <th scope="col">Microsyntax</th>
      <th scope="col">Description</th>
      <th scope="col">Examples</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Valid month string</td>
      <td><em>YYYY</em><code>-</code><em>MM</em></td>
      <td><code>2011-11</code>, <code>2013-05</code></td>
    </tr>
    <tr>
      <td>Valid date string</td>
      <td><em>YYYY</em><code>-</code><em>MM</em><code>-</code><em>DD</em></td>
      <td><code>1887-12-01</code></td>
    </tr>
    <tr>
      <td>Valid yearless date string</td>
      <td><em>MM</em><code>-</code><em>DD</em></td>
      <td><code>11-12</code></td>
    </tr>
    <tr>
      <td>Valid time string</td>
      <td>
        <em>HH</em><code>:</code><em>MM</em><br /><em>HH</em><code>:</code
        ><em>MM</em><code>:</code><em>SS</em><br /><em>HH</em><code>:</code
        ><em>MM</em><code>:</code><em>SS</em><code>.</code><em>mmm</em>
      </td>
      <td>
        <code>23:59</code><br /><code>12:15:47</code><br /><code
          >12:15:52.998</code
        >
      </td>
    </tr>
    <tr>
      <td>Valid local date and time string</td>
      <td>
        <em>YYYY</em><code>-</code><em>MM</em><code>-</code><em>DD</em>
        <em>HH</em><code>:</code><em>MM</em><br /><em>YYYY</em><code>-</code
        ><em>MM</em><code>-</code><em>DD</em> <em>HH</em><code>:</code
        ><em>MM</em><code>:</code><em>SS</em><br /><em>YYYY</em><code>-</code
        ><em>MM</em><code>-</code><em>DD</em> <em>HH</em><code>:</code
        ><em>MM</em><code>:</code><em>SS</em><code>.</code><em>mmm</em><br /><em
          >YYYY</em
        ><code>-</code><em>MM</em><code>-</code><em>DD</em><code>T</code
        ><em>HH</em><code>:</code><em>MM</em><br /><em>YYYY</em><code>-</code
        ><em>MM</em><code>-</code><em>DD</em><code>T</code><em>HH</em
        ><code>:</code><em>MM</em><code>:</code><em>SS</em><br /><em>YYYY</em
        ><code>-</code><em>MM</em><code>-</code><em>DD</em><code>T</code
        ><em>HH</em><code>:</code><em>MM</em><code>:</code><em>SS</em
        ><code>.</code><em>mmm</em>
      </td>
      <td>
        <code
          >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</code
        >
      </td>
    </tr>
    <tr>
      <td>Valid time-zone offset string</td>
      <td>
        <code>Z</code><br /><code>+</code><em>HHMM</em><br /><code>+</code
        ><em>HH</em><code>:</code><em>MM</em><br /><code>-</code><em>HHMM</em
        ><br /><code>-</code><em>HH</em><code>:</code><em>MM</em>
      </td>
      <td>
        <code>Z<br />+0200<br />+04:30<br />-0300<br />-08:00</code>
      </td>
    </tr>
    <tr>
      <td>Valid global date and time string</td>
      <td>
        <em
          >Any combination of a valid local date and time string followed by a
          valid time-zone offset string</em
        >
      </td>
      <td>
        <code
          >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</code
        >
      </td>
    </tr>
    <tr>
      <td>Valid week string</td>
      <td><em>YYYY</em><code>-W</code><em>WW</em></td>
      <td><code>2013-W46</code></td>
    </tr>
    <tr>
      <td>Four or more ASCII digits</td>
      <td><em>YYYY</em></td>
      <td><code>2013</code>, <code>0001</code></td>
    </tr>
    <tr>
      <td>Valid duration string</td>
      <td>
        <code>P</code><em>d</em><code>D</code><code>T</code><em>h</em
        ><code>H</code><em>m</em><code>M</code><em>s</em><code>S</code
        ><br /><code>P</code><em>d</em><code>D</code><code>T</code><em>h</em
        ><code>H</code><em>m</em><code>M</code><em>s</em><code>.</code>X<code
          >S</code
        ><br /><code>P</code><em>d</em><code>D</code><code>T</code><em>h</em
        ><code>H</code><em>m</em><code>M</code><em>s</em><code>.</code>XX<code
          >S</code
        ><br /><code>P</code><em>d</em><code>D</code><code>T</code><em>h</em
        ><code>H</code><em>m</em><code>M</code><em>s</em><code>.</code>XXX<code
          >S</code
        ><br /><code>P</code><code>T</code><em>h</em><code>H</code><em>m</em
        ><code>M</code><em>s</em><code>S</code><br /><code>P</code><code>T</code
        ><em>h</em><code>H</code><em>m</em><code>M</code><em>s</em
        ><code>.</code>X<code>S</code><br /><code>P</code><code>T</code
        ><em>h</em><code>H</code><em>m</em><code>M</code><em>s</em
        ><code>.</code>XX<code>S</code><br /><code>P</code><code>T</code
        ><em>h</em><code>H</code><em>m</em><code>M</code><em>s</em
        ><code>.</code>XXX<code>S</code><br /><em>w</em><code>w </code><em>d</em
        ><code>d </code><em>h</em><code>h </code><em>m</em><code>m </code
        ><em>s</em><code>s</code>
      </td>
      <td>
        <code
          >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</code
        >
      </td>
    </tr>
  </tbody>
</table>

## Syntax

```js
dateTimeString = timeElt.dateTime;
timeElt.dateTime = dateTimeString
```

## Example

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

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

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- The {{domxref("HTMLTimeElement")}} interface it belongs to.
