v2.0.0-rc.4
Theme

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

PropertyAttributeTypeDefaultDescription
valuevaluestring''ISO date or datetime to display
formatformatstring'YYYY-MM-DD HH:mm'Output format
timeZonetime-zonestring''IANA time zone used for explicit instants; empty uses the browser time zone

Format tokens

TokenDescriptionExample
YYYY, YYFour- or two-digit year2026, 26
M, MMMonth without or with zero-padding8, 08
D, DDDay without or with zero-padding1, 01
H, HH24-hour time without or with zero-padding6, 06
h, hh12-hour time without or with zero-padding6, 06
m, mmMinutes without or with zero-padding5, 05
s, ssSeconds without or with zero-padding9, 09
SSSMilliseconds123
A, aUpper- or lowercase meridiemPM, 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-DD and ISO datetimes such as 2026-08-11T14:30, 2026-08-11T14:30:45.123456Z, or 2026-08-11T14:30:45+08:00. Fractional seconds are truncated to milliseconds for the SSS token.
  • Date-only and offsetless datetime values are wall-clock values; time-zone does not shift them.
  • A value with Z or an explicit offset represents an instant. It is converted to time-zone, or the browser’s local time zone when time-zone is 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

PartDescription
timeThe semantic <time> element

Accessibility

The formatted text remains machine-readable because the original ISO value is retained in the inner <time datetime="..."> attribute.