Relative Time
"5 minutes ago", "yesterday", "in 3 days" — a date said relative to now in the tectra locale.
Part of @tectra-ng/utils (npm install @tectra-ng/utils, also included in tectra-ng).
Basic
Within a day the pipe counts minutes and hours; past midnight it switches to calendar days, then months and years.
| Deploy finished | now |
| Comment added | 7 minutes ago |
| Report scheduled | tomorrow |
| Invoice paid | 2 days ago |
| Trial ends | in 12 days |
| Account created | last year |
Options
granularity: 'day' speaks in days only, largestUnit stops at days or months, numeric: 'always' drops "yesterday" for "1 day ago", style shortens the units.
default | 2 hours ago | yesterday | last month |
granularity: 'day' | today | yesterday | last month |
largestUnit: 'day' | 2 hours ago | yesterday | 45 days ago |
numeric: 'always' | 2 hours ago | 1 day ago | 1 month ago |
style: 'short' | 2 hr. ago | 1 day ago | 1 mo. ago |
Live
Pass now from a ticking signal and the text keeps up: post a message and watch it age. In an app TxClock.now is that signal.
Locale
The pipe follows the tectra locale — this example has its own TxLocaleService, so switching it here leaves the rest of the site alone. Pass locale for a single value.