Reputation: 461
I am using the react-datetime-picker npm module for selecting date.I need to display the date only without time
import DatePicker from 'react-datetime-picker';
onChange(date){
this.setState({
profileSetting:{dob:date}
});
}
<DatePicker className="form-control"
disableClock={true}
locale="en-US"
onChange={this.onChange}
value={this.state.profileSetting.dob}
/>
present date displayed like "10/20/2018 12:00 AM" but i need to display date like "10/20/2018".Please help me out of this issue
Upvotes: 0
Views: 6878
Reputation: 11
Kindly use bootstrap input and put type = "text"
**<input type="date" />**
If you use this u don't need another library and use instead react hook forms which will handle controlled components in your forms
Upvotes: 0
Reputation: 1974
In on onChange
method, you can simply format your date as per your requirement
const selectedDate = new Date('10/20/2018 12:00 AM'); // pass in date param here
const formattedDate = `${selectedDate.getMonth()+1}/${selectedDate.getDate()}/${selectedDate.getFullYear()}`;
console.log(formattedDate);
Upvotes: 2