catamphetamine / javascript-time-ago

International highly customizable relative date/time formatting

Home Page:https://catamphetamine.gitlab.io/react-time-ago/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Only show Days Ago?

lightninglu10 opened this issue · comments

Is there a way to only show timeago in days? It's hard for me to parse the documentation and it's not clear whether gradation should be used and how it should be used.

For anyone who stumbles across this, just figured out that you have to specify factor:

let timeAgoComponents = timeAgo.format(
          new Date(this.props.lastActivityAt), {
          flavour: 'short',
          gradation: [
            {
              factor: 86400,
              unit: 'day',
            },
          ]
        });