gpt4 book ai didi

reactjs - 我只想发布日期而不是日期选择器

转载 作者:行者123 更新时间:2023-12-03 13:51:30 24 4
gpt4 key购买 nike

我想在 table.when 列中发布日期来代替日期选择器 我将日期选择器发布在列的表格中,它应该被转换 例如,当我发布今天的日期时,它应该显示 1 天 在表格的列中,明天为 2 天,依此类推。 the screenshot of my project is here .如何解决这个问题,请帮帮我。

我的项目的代码如下所示。它只发布日期而不是日期。

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);
});
}

我正在使用引导表来显示这样的日期

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

日期选择器的形式是这样的。

 <DatePicker label='Date'  onChange={(text) => this.setState({timestampBalance: text})} value={this.state.timestampBalance} />

最佳答案

在这里回答一个老问题:您可以使用 difference function in moment

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

如果您希望今天为 1,只需在差异中添加 1 即可。

关于reactjs - 我只想发布日期而不是日期选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39093293/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com