javascript – How convert timestamp to date react js ,, i need it in days only please Note: i’m using antd library

google it

I googled this question so

// how to convert timestamp to date
function timeConverter(UNIX_timestamp){
  var a = new Date(UNIX_timestamp * 1000);
  var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
  var year = a.getFullYear();
  var month = months[a.getMonth()];
  var date = a.getDate();
  var hour = a.getHours();
  var min = a.getMinutes();
  var sec = a.getSeconds();
  var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
  return time;
}
console.log(timeConverter(0));

And subtract date

// This will give you the difference between two dates, in milliseconds
 const timeInterval = Math.abs(end - start )

The timeInterval need to be days only? just do some division
And I think it’s okay to find a package to do these things, there is no need to do it manually

Read more here: Source link