Reputation:
I am using moment to get the time to an event and am using the fromNow
functionality
moment(value).fromNow();
This works well, however, and it tells me in 4 days
. The issue is that if it less than a day then it says in 4 hours
. Instead of this I would prefer it would say today
.
I have updated moment.updateLocale()
, however it now says in today
.
Does anyone know how to rectify this with moment
?
moment.updateLocale('en', {
relativeTime: {
future: "in %s",
past: "%s ago",
s: "today",
m: "today",
mm: "today",
h: "today",
hh: "today",
d: "1 day",
dd: "%d days",
}
});
Upvotes: 3
Views: 619
Reputation: 1727
From the docs: If you pass true, you can get the value without the suffix. https://momentjs.com/docs/#/displaying/fromnow/
moment(value).fromNow(true);
Combine it with your translations
Upvotes: 1