I use the am-time-ago
directive to show a relative timestamp:
<span am-time-ago="publishedAt"></span>
By default, it is formatted as "a day ago", "5 days ago", etc.
How could I change the formatting to be "1d", "5d", "3h", etc?
I use the am-time-ago
directive to show a relative timestamp:
<span am-time-ago="publishedAt"></span>
By default, it is formatted as "a day ago", "5 days ago", etc.
How could I change the formatting to be "1d", "5d", "3h", etc?
You could customize humanize, somewhere in your config or app start.
Docs on realtiveTime
Example: http://jsbin.com/satohazu/1/edit
The accepted answer by Nix works, but is deprecated by now. Anybody who stumbles across this discussion (like I did) should use
moment.updateLocale(locale)
.Details at https://momentjs.com/docs/#/customization/relative-time/