I want to send days only instead of datepicker

I want to send days instead of datepicker to table.when column I send datepicker to table column, it should be converted to days. For example, when I post a date today, it should show 1 day in the column table, 2 days for tomorrowow and so on. a screenshot of my project is here . How to solve this problem, please help me.

my project code looks like this. This is only the publication date, not the days.

const datetime = new Date(2016, 8, 20);
export default class SupportInterface extends Component {
constructor(props) {
super (props);
this.state = {
  active: false,
  socket: null,
  timestampBalance:datetime,
  supportInfo: [],
  modalComapnyName:'',
  modalVehicleNo:'',
  modalSimNo:'',
  modalLat: '27.931963',
  modalLng: '84.85758'

}

this code sends the date from the form.

 saveForm(){ 
axios({
method:'post',
url: 'https://something.something.com.np/updateRechargeStatus',
data:{
  timestamp:moment(this.state.timestampBalance).format("MMM DD,         YYYY"),
  balance: '51',
  sim_number:this.state.modalSimNo
}
})
.then((response)=>{
  if(response.data.success){
  this.setState({
    active:false
  });
  this.getSupportInfo();
}else{
  alert("unable to update balance");

}
})
.catch((error)=>{
throw('error',error);
});
}

I use the bootstrap table to show a date like this

<TableHeaderColumn dataField="timestamp_for_balance" dataSort={true}>Recharge date</TableHeaderColumn>

The datepicker form is as follows.

 <DatePicker label='Date'  onChange={(text) => this.setState({timestampBalance: text})} value={this.state.timestampBalance} />
+4
source share
1 answer

:

var a = moment(this.state.timestampBalance);
var b = moment();
a.diff(b, 'days') //number of days between today and timestampBalanceDate

, 1, 1 diff.

+1

Source: https://habr.com/ru/post/1652137/


All Articles