{"repo":"github/relative-time-element","free":true,"listed":false,"github":"https://github.com/github/relative-time-element","clone":"git clone https://github.com/github/relative-time-element.git","description":"Web component extensions to the standard <time> element.","language":"JavaScript","stars":4016,"topics":["web-components","custom-elements","timezone","localization","keep"],"license":"MIT","category":"ui-components","readme_excerpt":"&lt;relative-time&gt; element 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. Installation 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 . Usage Add a 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: - 6 years from now - 20 days from now - 4 hours from now - 7 minutes from now","default_branch":null,"files":null,"tree":[],"storefront":"/r/github","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/github/relative-time-element/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}