Please I received a response from a REST API, and in the JSON object, the time value was a timestamp. However, I need to render it as a "number of days" kind of format.
I received this particular time stamp: "2022-01-12T13:05:16Z"
I want to render it as something like "5 days ago"
How do I go about this please?
transform the current date and the date you want to milliseconds with .getTime() then subtract it then split the result to milliseconds in a day and you get the number of days passed, Math.ceil to round the number up
console.log(Math.ceil((new Date().getTime() - new Date("2022-01-12T13:05:16Z").getTime()) / 86400000))