//Set new date
this.state.startDate = new Date("July 27, 1962 23:30:00")
const date = new Date(this.state.startDate);
//Set hours
date.setHours(0, 0, this.state.second);
date.toTimeString();
When I click edit. I want this date to be displayed in the input. And that it can be edited
Picture: https://imgur.com/OjBEC5u
Example here: https://stackblitz.com/edit/react-cuubsx
Edit
class Edit extends React.Component {
render() {
return (
<DatePicker
selected={this.props.startDate}
onChange={this.props.handleChange}
/>
)
}
}
Item
class Item extends Component {
state = {
startDate: new Date("July 27, 1962 23:30:00"),
second: 120
}
handleChange = (date) => {
this.setState({
startDate: date
});
}
render() {
const date = new Date(this.state.startDate);
console.log(date)
date.setHours(0, 0, this.state.second);
date.toTimeString();
return (
<Edit
handleChange={this.handleChange}
startDate={date}
handleDescription={this.handleDescription}
date = {this.date}
/>
)
}
}
from DatePicker does not display the date in input when editing
No comments:
Post a Comment