github

    github/relative-time-element

    Web component extensions to the standard <time> element.

    frontend
    custom-elements
    keep
    localization
    timezone
    web-components
    JavaScript
    MIT
    4.0K stars
    198 forks
    4.0K GitHub watchers
    Updated Nov 4, 2026
    View on GitHub

    Build with Backblaze B2

    SDKs, agent skills, IDE extensions, and reference pipelines from Backblaze Labs. All open source.

    Explore Backblaze Labs

    Loading star history...

    Where it stands

    Rank, growth pace and release cadence relative to everything GStars tracks.

    No releases in the last 90 days; the most recent was 93 days ago, with 67 contributors on GitHub.

    Gained 9% more stars in the last 90 days than in the 90 days before.

    Use Cases & Benefits

    • Formats timestamps as localized or relative time strings that auto-update in the browser using a custom web component.
    • Enables server-side caching of static date markup while localizing and updating time display dynamically per user locale and timezone.
    • Use for displaying user-friendly relative timestamps in web apps that respect user locale and timezone preferences.
    • Use for embedding accessible, auto-updating time elements in static HTML content served from caches or CDNs.
    • Use for building internationalized UI components that require precise control over date/time formatting and relative time thresholds.

    Should you depend on it?

    License terms, project hygiene and risks, from GitHub metadata and GStars' snapshots.

    License

    MIT

    Permissive: commercial use, modification and redistribution are allowed with attribution.

    Community files

    • README: present
    • Contributing guide: present
    • Code of conduct: present

    Watch-outs

    No watch-outs from GStars' checks.

    General guidance from repository metadata, not legal advice. How we score

    From the README

    Formats a timestamp as a localized string or as relative text that auto-updates in the user's browser.

    This allows the server to cache HTML fragments containing dates and lets the browser choose how to localize the displayed time according to the user's preferences. For example, the server may have cached the following generated markup:

    Every visitor is served the same markup from the server's cache. When it reaches the browser, the custom relative-time JavaScript localizes the element's text into the local timezone and formatting.

    Dates are displayed before months, and a 24-hour clock is used, according to the user's browser settings.

    If the browser's JavaScript is disabled, the default text served in the cached markup is still displayed.

    Available on npm as @github/relative-time-element.

    This element uses the Intl.DateTimeFormat & Intl.RelativeTimeFormat APIs, which are supported by all modern JS engines. If you need to support an older browser, you may need to introduce a polyfill for Intl.DateTimeFormat & Intl.RelativeTimeFormat.

    Add a <relative-time> element to your markup. Provide a default formatted date as the element's text content (e.g. April 1, 2014). It also MUST have a datetime attribute set to an ISO 8601 formatted timestamp.

    Depending on how far in the future this is being viewed, the element's text will be replaced with one of the following formats:

    So, a relative date phrase is used for up to a month and then the actual date is shown.

    Excerpt from the github/relative-time-element README on GitHub (MIT license). © its authors.Read the full README on GitHub

    Daily snapshots

    Stars gained per day, and how forks and open issues moved, from GStars' daily snapshots

    Forks

    198+7

    Open issues

    23-1

    Compared with peers in Frontend

    Fastest-growing repositories GStars tracks in this cohort for the week of Nov 1, by 7-day star growth

    github/relative-time-element compared with Frontend repositories by stars, 7-day star growth, health score and last release
    RepositoryStars+7dHealthLast release
    Leonxlnx/taste-skill110.7K+5.2K551 day ago
    heygen-com/hyperframes79.6K+4.1K45today
    DuarteSantos8/openGym19.7K+2.4K602 days ago
    remotion-dev/remotion71.1K+2.2K45today
    chthollyphile/folia-major11.7K+1.5K40today
    github/relative-time-element4.0K—6093 days ago
    Category median71.1K+2.4K45—

    Also by github

    Other repositories from this maintainer that GStars tracks

    Discover Repositories

    Search across tracked repositories by name or description