Convert UTC time to most recent text using moment property local and fromNow

How to get recent local time post date from a post stored in UTC date format.

moment(this.post.created_at,’YYYY-MM-DD H:m:s’).utc(‘YYYY-MM-DD H:m:s’).local().fromNow()

Here is the basic funda you need to follow

my current post time stored in this.post.created_at

i am converting it into moment using moment.js

moment(this.post.created_at,’YYYY-MM-DD H:m:s’)

Now we need to get the UTC format of it so

moment(this.post.created_at,’YYYY-MM-DD H:m:s’).utc(‘YYYY-MM-DD H:m:s’)

Covert this time to local using moment property.

moment(this.post.created_at,’YYYY-MM-DD H:m:s’).utc(‘YYYY-MM-DD H:m:s’).local()

At last use this time to get the difference from current time Using fromNow property of moment.

moment(this.post.created_at,’YYYY-MM-DD H:m:s’).utc(‘YYYY-MM-DD H:m:s’).local().fromNow()

Good luck guys Its working for me.