How do I convert this:
2017-08-14T23:28:56.782Z
Into relative time e.g. "21d". If there is an npm dependency I can use that too.
How do I convert this:
2017-08-14T23:28:56.782Z
Into relative time e.g. "21d". If there is an npm dependency I can use that too.
 
    
    there are some useful library like momentjs which will easy the way.
var a = moment([2007, 0, 29]);
var b = moment([2007, 0, 28]);
a.diff(b, 'days') // 1
 
    
    Using moment.js, you can do moment("2017-08-14T23:28:56.782Z").fromNow();. This will give you 21 days ago
console.log(moment("2017-08-14T23:28:56.782Z").fromNow());<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js'></script> 
    
     
    
    If you mean 21 days ago, then Moment.js is convenient for things like that. There is also react-datetime, but I don't have any experience using it with React, so I can't comment on its efficacy or ease of use.
