I'm trying to show how many time went since the creation on a post! after searching I found that I have to use momentJs. The time is stored like this:
And I used this code to show the time
{moment.utc(post.createdAt).local().startOf('seconds').fromNow()}
and the output is like this:
now the question is how change the output to arabic language?
CodePudding user response:
You should add before moment
moment.locale('ar_SA'); //for Arabia
CodePudding user response:
First I should import the Arabic library
import 'moment/locale/ar'
then
moment.locale('ar');
const daysAgo = moment(post.createdAt);
And then return it
<span>
{daysAgo.fromNow()}
</span>