I am trying to show the least minimum time segment based on a unix timestamp.
Example:
- "50 seconds ago" needs to be 50s.
- "65 seconds ago" needs to be 1m because its more 60 seconds is in minutes.
- "65 minutes ago" needs to be 1h because its more 60 minutes is in minutes.
- "25 hours ago" => 1d.
- "8 days ago" => 1w.
- ... 1mon (for months).
- ... 2y (for years).
I have tried a few libraries like moment i.e.
moment.unix(1440187622).fromNow()
but that returns a "sentence", however its not exactly what I want.
Any ideas?