I am trying code snippet in React. How can I make the created_at attribute in human-readable form in react just like in PHP laravel framework provides us diffForHumans() function to do so?
<div className="media-body">
<h3 className="mt-0"><a href="">{question.title}</a></h3>
<p className="lead">
Asked By
<a href="{question.user.url}" className={"px-2"}>
{question.user.name}
</a>
<small className="text-muted px-1">{question.created_at}
</small>
</p>
<p className="small">{question.body.substring(0, 250) + '...'}</p>
<hr/>
</div>
You can see the full code here: https://codepen.io/osman-rafi/pen/ZEzdozJ
In <small className="text-muted px-1">{question.created_at}</small> provies output like 2019-09-26 08:26:18, but i want in more readable form like '2 days ago' or 'one hour ago'.
Thanks in advance!