I am building a web application which requires date to be entered, but on entering a date it will be saved in mm-dd-yyyy and on using bootstrap it will be saved in yyyy-mm-dd format.
Below is the code.
searchTrain(e) {
e.preventDefault();
this.props.trains(this.state)
this.setState({ to: '', from: '', date: '' })
}
onChangeTrain(e) {
this.setState(
{ [e.target.id]: e.target.value }
// , () => console.log(this.state)
);
}
<div className="col" >
<label >
<span>Journey Date <span className="required">*</span></span>
<input type="date" className="input-field" id="date"
value={this.state.date} onChange={this.onChangeTrain}
/>
</label>
</div>