DEV Community

Cover image for Current time tag
Dev Ieffe
Dev Ieffe

Posted on • Edited on

Current time tag

Proposal

Introduce a lightweight HTML element for rendering the user’s current date and time, with simple, human-readable formatting options.

<current-time attr="s,m,h,d,m:text-full,y:full"/>
Enter fullscreen mode Exit fullscreen mode

Idea

The tag prints the live time in the user’s locale, updating every second (or on a specified interval). The attr attribute is a concise format string describing which parts to show and how to style them:

  • s, m, h, d, m, y → seconds, minutes, hours, day, month, year
  • :text-full → full month/day names (e.g., “September”)
  • :text-short → abbreviated names (e.g., “Sep”)
  • :2 → zero-padded (e.g., 09)
  • :full → four-digit year.

Examples

<!-- 24-hour clock with seconds -->
<current-time attr="h:2,m:2,s:2"/>

<!-- Friendly long date -->
<current-time attr="d,m:text-full,y:full"/>

<!-- Locale-aware month + year -->
<current-time attr="m:text-short,y:full"/>
Enter fullscreen mode Exit fullscreen mode

Accessibility

  • Respects user locale/time
  • Uses aria-live="polite" so screen readers announce updates unobtrusively
  • Degrades gracefully: server can prerender a static timestamp inside the element; a small client script hydrates and starts updates if JS is available.

Why

Authors often reinvent clocks with verbose JavaScript, inconsistent formatting, and poor accessibility. A declarative tag reduces code, improves semantics, and standardizes behavior across sites.

Open questions

Update frequency control, CPU/battery constraints (pause when offscreen), relative time (from-now), and integration with

Top comments (1)

Collapse
 
moopet profile image
Info Comment hidden by post author - thread only accessible via permalink
Ben Sinclair

I'm not sure what you're asking?

Some comments have been hidden by the post's author - find out more