# The text content of element “time” was not in the required format: The literal did not satisfy the time-datetime format.

> Canonical HTML version: https://rocketvalidator.com/html-validation/the-text-content-of-element-time-was-not-in-the-required-format-the-literal-did-not-satisfy-the-time-datetime-format
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `<time>` element represents a specific moment or duration in time. Browsers, search engines, and assistive technologies rely on parsing its value to understand temporal data programmatically. The element can get its machine-readable value from two places: the `datetime` attribute, or, if that attribute is absent, from the element's text content directly.

When there is no `datetime` attribute, the text content itself **must** be in one of the valid formats specified by the HTML standard. This is where the error typically occurs—authors write a human-readable date like "March 20, 2025" or "last Tuesday" as the text content without providing a `datetime` attribute, and the validator rejects it because that string isn't machine-parsable.

## Why This Matters

- **Machine readability:** Search engines (via structured data) and browser features (like calendar integration) depend on parsing the `<time>` element's value. An invalid format means these tools can't understand the date or time.
- **Accessibility:** Screen readers and other assistive technologies may use the machine-readable datetime to present temporal information more helpfully to users.
- **Standards compliance:** The HTML specification explicitly defines which formats are valid. Using anything else makes your document non-conforming.

## How to Fix It

You have two options:

1. **Add a `datetime` attribute** with the machine-readable value, and keep the human-readable text as the visible content. This is the most common and practical approach.
2. **Use a valid format directly as the text content** if you don't mind displaying a machine-readable format to users.

## Valid Formats

Here is a reference of accepted formats for the `<time>` element:

| Type | Example(s) |
|------|-----------|
| Valid year | `2011` |
| Valid month | `2011-11` |
| Valid date | `2011-11-18` |
| Valid yearless date | `11-18` |
| Valid week | `2011-W47` |
| Valid time | `14:54`, `14:54:39`, `14:54:39.929` |
| Valid local date and time | `2011-11-18T14:54:39.929` or `2011-11-18 14:54:39.929` |
| Valid global date and time | `2011-11-18T14:54:39.929Z`, `2011-11-18T14:54:39.929-04:00` |
| Valid duration | `PT4H18M3S`, `P2D` (2 days), `P3DT4H` (3 days, 4 hours) |

## Examples

### Incorrect: Human-readable text without `datetime` attribute

The validator will report the error because "March 20, 2025" is not a valid machine-readable format:

```html
<p>The concert is on <time>March 20, 2025</time>.</p>
```

### Incorrect: Informal text as content

Similarly, casual date strings are not valid:

```html
<p>Updated <time>last Friday</time>.</p>
```

### Correct: Using the `datetime` attribute

Add a `datetime` attribute with the machine-readable value and keep the human-friendly text visible:

```html
<p>The concert is on <time datetime="2025-03-20">March 20, 2025</time>.</p>
```

### Correct: Including time and timezone

```html
<p>
  The event starts at
  <time datetime="2025-03-20T13:00-05:00">1:00 PM EST on March 20, 2025</time>.
</p>
```

### Correct: Machine-readable format as text content

If no `datetime` attribute is provided, the text content itself must be a valid format:

```html
<p>Date: <time>2025-03-20</time></p>
```

### Correct: Representing a duration

```html
<p>Cooking time: <time datetime="PT1H30M">1 hour and 30 minutes</time>.</p>
```

### Correct: Using just a time value

```html
<p>The shop opens at <time>09:00</time> every day.</p>
```

As a general rule, whenever you want to display a date or time in a natural, human-friendly way, always pair it with a `datetime` attribute that contains the machine-readable equivalent. This keeps your HTML valid, your content accessible, and your temporal data useful to machines.
