2016-08-23 10 views
4

私はテーブルの列にdatepickerの代わりに日を投稿したい。 私は列のテーブルにdatepickerを投稿し、それは 日に変換する必要があります。私は今日の日付を記入して、それは列のテーブルに 1日、tommorowのように2日間を表示する必要があります。 the screenshot of my project is here。この問題を解決するには、私を助けてください。私は日付ピッカーの代わりに日だけ投稿したい

私のプロジェクトのコードはthis.itのように見えます。

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

私は、DatePickerのフォームは、このようなものです。この

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

などの日付を表示するには、ブートストラップのテーブルを使用しています。あなたは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を追加しますので、を使用することができます:ここに古い質問に拾い

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

答えて

関連する問題