Datetime
<el-dm-datetime> renders an ISO date or datetime as formatted, display-only text. It
uses a semantic <time> element internally and does not expose any editing controls.
Installation
npm install @duskmoon-dev/el-datetime
Usage
import '@duskmoon-dev/el-datetime/register';
<el-dm-datetime value="2026-08-11T14:30:45" format="YYYY-MM-DD HH:mm:ss"></el-dm-datetime>
Live demos
Date and time
Custom format with literal text
Time-zone conversion
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | '' | ISO date or datetime to display |
format | format | string | 'YYYY-MM-DD HH:mm' | Output format |
timeZone | time-zone | string | '' | IANA time zone used for explicit instants; empty uses the browser time zone |
Format tokens
| Token | Description | Example |
|---|---|---|
YYYY, YY | Four- or two-digit year | 2026, 26 |
M, MM | Month without or with zero-padding | 8, 08 |
D, DD | Day without or with zero-padding | 1, 01 |
H, HH | 24-hour time without or with zero-padding | 6, 06 |
h, hh | 12-hour time without or with zero-padding | 6, 06 |
m, mm | Minutes without or with zero-padding | 5, 05 |
s, ss | Seconds without or with zero-padding | 9, 09 |
SSS | Milliseconds | 123 |
A, a | Upper- or lowercase meridiem | PM, pm |
Token letters in ordinary text are interpreted as tokens. Wrap literal text in square brackets:
<el-dm-datetime value="2026-08-11T14:30:45" format="YYYY-MM-DD [at] h:mm A"></el-dm-datetime>
Input and time-zone behavior
- Accepted values are
YYYY-MM-DDand ISO datetimes such as2026-08-11T14:30,2026-08-11T14:30:45.123456Z, or2026-08-11T14:30:45+08:00. Fractional seconds are truncated to milliseconds for theSSStoken. - Date-only and offsetless datetime values are wall-clock values;
time-zonedoes not shift them. - A value with
Zor an explicit offset represents an instant. It is converted totime-zone, or the browser’s local time zone whentime-zoneis omitted. - Invalid values, impossible dates, and invalid time-zone names render empty content.
Use an explicit Z or offset whenever time-zone conversion matters.
CSS parts
| Part | Description |
|---|---|
time | The semantic <time> element |
Accessibility
The formatted text remains machine-readable because the original ISO value is retained in
the inner <time datetime="..."> attribute.