I am using newsapi.org to get news data and date-fns library. How can I get difference between PublishedTime of article which is in UTC+000 (e.g: 2020-09-13T15:50:00Z) and current datetime?
What i have tried:
import { formatDistance } from "date-fns";
timeDistance = (time) => {
return formatDistance(new Date(), time);
};
where time is a string: e.g: "2020-09-13T15:50:00Z"
Expected result: something like 10 minutes ago, 1 hour ago etc.