Reactjs 我只想发布天而不是日期选择器
我想在table.when列中用days代替datepicker 我在列的表中发布了日期选择器,它应该被转换 以天为单位。例如,当我发布今天的日期时,它应该显示1天 在列的表格中,2天用于tommorow,依此类推。如何解决这个问题,请帮我解决 我的项目代码如下所示。它只发布日期而不是天数Reactjs 我只想发布天而不是日期选择器,reactjs,Reactjs,我想在table.when列中用days代替datepicker 我在列的表中发布了日期选择器,它应该被转换 以天为单位。例如,当我发布今天的日期时,它应该显示1天 在列的表格中,2天用于tommorow,依此类推。如何解决这个问题,请帮我解决 我的项目代码如下所示。它只发布日期而不是天数 const datetime = new Date(2016, 8, 20); export default class SupportInterface extends Component { constr
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'
}
此代码从表单中发布日期
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);
});
}
我用bootstrap表来显示这样的日期
<TableHeaderColumn dataField="timestamp_for_balance" dataSort={true}>Recharge date</TableHeaderColumn>
充值日期
日期选择器窗体如下所示
<DatePicker label='Date' onChange={(text) => this.setState({timestampBalance: text})} value={this.state.timestampBalance} />
this.setState({timestampBalance:text})value={this.state.timestampBalance}/>
在这里,您可以使用
如果你想今天成为1,只需在差异中加上1
var a = moment(this.state.timestampBalance);
var b = moment();
a.diff(b, 'days') //number of days between today and timestampBalanceDate