javascript-time-ago
Automatically chooses the right units (seconds, minutes, etc) to format a time interval.
Official Documentation ↗v6.2.2. Check the official docs for the latest API surface.Installation
npm install javascript-time-agopnpm add javascript-time-agoMethods
No methods match this filter.
Overview
Automatically chooses the right units (seconds, minutes, etc) to format a time interval. Examples: just now 45s 5m 15 minutes ago 3 hours ago in 2 months in 5 years … For React users, there’s a React version — [See Demo](https://catamphetamine.gitlab.io/react-time-
API reference status
This page lists only entry points that appear verbatim in the official README examples: TimeAgo, getMinTimeForUnit, formatAs. Parameter and return types are not given by the official README, so signatures are marked unverified.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/catamphetamine/javascript-time-ago@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:29.606Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- If the “default language” hasn’t been added, an error is thrown. (https://cdn.jsdelivr.net/gh/catamphetamine/javascript-time-ago@latest/README.md)
Verification notes
- Official source: https://github.com/catamphetamine/javascript-time-ago
- Evidence: https://cdn.jsdelivr.net/gh/catamphetamine/javascript-time-ago@latest/README.md
- Checked on 2026-11-04 by
scripts/phase11/build-api-profiles.mjs
API reference evidence
Fetched from official sources on 2026-11-08T18:34:00+08:00 via WebFetch https://cdn.jsdelivr.net/gh/catamphetamine/javascript-time-ago@latest/README.md;WebFetch https://cdn.jsdelivr.net/gh/catamphetamine/javascript-time-ago@latest/index.d.ts.
TimeAgo→ signature from https://cdn.jsdelivr.net/gh/catamphetamine/javascript-time-ago@latest/index.d.ts; official text: “export default class TimeAgo { constructor(locale: Locale | Locale[], options?: { polyfill?: boolean }); format(date: DateInput, style?: FormatStyleName | Style, options?: FormatOptions): string | [string, number?];”
FAQ
- What does javascript-time-ago do?
- Automatically chooses the right units (seconds, minutes, etc) to format a time interval.
- How do I install javascript-time-ago?
- Run `npm install javascript-time-ago`.
- Where can I verify the API details?
- Official repository/documentation: https://github.com/catamphetamine/javascript-time-ago. Checked on 2026-11-04; signatures and return values not stated in the official README are marked unverified.
Report a problem with this API docOpens a pre-filled issue on GitHub.