{"id":14990105,"url":"https://github.com/chrisburnell/relative-time","last_synced_at":"2025-10-28T08:17:40.467Z","repository":{"id":233031103,"uuid":"785676596","full_name":"chrisburnell/relative-time","owner":"chrisburnell","description":"A Web Component to display a relative time. There are many like it, but this one is mine.","archived":false,"fork":false,"pushed_at":"2024-08-11T14:27:38.000Z","size":55,"stargazers_count":34,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-09T07:36:24.148Z","etag":null,"topics":["custom-element","custom-elements","customelement","customelements","javascript","web-component","web-components","webcomponent","webcomponents"],"latest_commit_sha":null,"homepage":"https://chrisburnell.com/relative-time/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrisburnell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"chrisburnell","buy_me_a_coffee":"chrisburnell"}},"created_at":"2024-04-12T11:40:40.000Z","updated_at":"2024-12-06T23:45:05.000Z","dependencies_parsed_at":"2024-04-13T02:33:13.247Z","dependency_job_id":"fcde168b-cca8-4f40-9147-bd265ab59e51","html_url":"https://github.com/chrisburnell/relative-time","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"45991bb3acdb435b4074d7e231b82f65039a877d"},"previous_names":["chrisburnell/relative-time"],"tags_count":13,"template":false,"template_full_name":"daviddarnes/component-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisburnell%2Frelative-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisburnell%2Frelative-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisburnell%2Frelative-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisburnell%2Frelative-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisburnell","download_url":"https://codeload.github.com/chrisburnell/relative-time/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542288,"owners_count":18242332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-element","custom-elements","customelement","customelements","javascript","web-component","web-components","webcomponent","webcomponents"],"created_at":"2024-09-24T14:19:27.816Z","updated_at":"2025-10-28T08:17:40.447Z","avatar_url":"https://github.com/chrisburnell.png","language":"JavaScript","funding_links":["https://github.com/sponsors/chrisburnell","https://buymeacoffee.com/chrisburnell"],"categories":[],"sub_categories":[],"readme":"# `\u003crelative-time\u003e`\n\nA Web Component to display a relative time (e.g. \"5 minutes ago\", \"in 2 days\"). Uses the built-in `Intl.RelativeTimeFormat` API.\n\n**[Demo](https://chrisburnell.github.io/relative-time/demo.html)** | **[Further reading](https://chrisburnell.com/relative-time/)**\n\n## Examples\n\n### General usage example\n\n```html\n\u003cscript type=\"module\" src=\"relative-time.js\"\u003e\u003c/script\u003e\n\n\u003crelative-time\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n```\n\n### Explicit locale\n\n```html\n\u003cscript type=\"module\" src=\"relative-time.js\"\u003e\u003c/script\u003e\n\n\u003crelative-time lang=\"fr\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n```\n\n### Inherited locale\n\n```html\n\u003cscript type=\"module\" src=\"relative-time.js\"\u003e\u003c/script\u003e\n\n\u003cp lang=\"fr\"\u003e\n    \u003crelative-time\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n\u003c/p\u003e\n```\n\n### Update frequency\n\n```html\n\u003cscript type=\"module\" src=\"relative-time.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Updates every 1 second --\u003e\n\u003crelative-time update=\"1\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n\n\u003c!-- Disable updates --\u003e\n\u003crelative-time update=\"false\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n```\n\n### Specific division\n\n```html\n\u003cscript type=\"module\" src=\"relative-time.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Always format using seconds --\u003e\n\u003crelative-time division=\"second\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n```\n\n### Maximum division\n\n```html\n\u003cscript type=\"module\" src=\"relative-time.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Format using seconds up to minutes --\u003e\n\u003crelative-time max-division=\"minute\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n```\n\n### Numeric format\n\n```html\n\u003cscript type=\"module\" src=\"relative-time.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Automatically choose when to use numbers vs. words in formatting --\u003e\n\u003crelative-time format-numeric=\"auto\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n\n\u003c!-- Always use numbers in time formatting --\u003e\n\u003crelative-time format-numeric=\"always\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n```\n\n### Style format\n\n```html\n\u003cscript type=\"module\" src=\"relative-time.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Long formatting (e.g. 1 second) --\u003e\n\u003crelative-time format-style=\"long\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n\n\u003c!-- Short formatting (e.g. 1 sec.) --\u003e\n\u003crelative-time format-style=\"short\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n\n\u003c!-- Narrow formatting (e.g. 1s) --\u003e\n\u003crelative-time format-style=\"narrow\"\u003e\u003ctime datetime=\"2024-04-09T00:00:00+14:00\"\u003e9 April 2024\u003c/time\u003e\u003c/relative-time\u003e\n```\n\n## Installation\n\nYou have a few options (choose one of these):\n\n1. Install via [npm](https://www.npmjs.com/package/@chrisburnell/relative-time): `npm install @chrisburnell/relative-time`\n1. [Download the source manually from GitHub](https://github.com/chrisburnell/relative-time/releases) into your project.\n1. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)\n\n## Usage\n\nMake sure you include the `\u003cscript\u003e` in your project (choose one of these):\n\n```html\n\u003c!-- Host yourself --\u003e\n\u003cscript type=\"module\" src=\"relative-time.js\"\u003e\u003c/script\u003e\n```\n\n```html\n\u003c!-- 3rd party CDN, not recommended for production use --\u003e\n\u003cscript\n  type=\"module\"\n  src=\"https://www.unpkg.com/@chrisburnell/relative-time/relative-time.js\"\n\u003e\u003c/script\u003e\n```\n\n```html\n\u003c!-- 3rd party CDN, not recommended for production use --\u003e\n\u003cscript\n  type=\"module\"\n  src=\"https://esm.sh/@chrisburnell/relative-time\"\n\u003e\u003c/script\u003e\n```\n\n## Credit\n\nWith thanks to the following people:\n\n- [David Darnes](https://darn.es) for creating this [Web Component repo template](https://github.com/daviddarnes/component-template)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisburnell%2Frelative-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisburnell%2Frelative-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisburnell%2Frelative-time/lists"}