Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for relative date/time? #111

Open
gukii opened this issue Mar 2, 2019 · 1 comment
Open

Support for relative date/time? #111

gukii opened this issue Mar 2, 2019 · 1 comment

Comments

@gukii
Copy link

gukii commented Mar 2, 2019

Hi,

Congrats on the good work that you are doing!

Question. Do you plan to support for displaying dates relative to "now"

e.g.:
5 min ago
2 hours ago
2 days ago
...

react-intl has support for it, or maybe incorporate something like "react-timeago"

@cwtuan
Copy link
Collaborator

cwtuan commented Mar 4, 2019

Thanks for the suggestion.
Currently, you could use moment.js for this purpose.
JS:

const ago = moment(new Date()).fromNow();
return (<div>{intl.get("key", {ago})}</div>);

Locale:

{
   "key" : "Published {ago}"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants