React Datepicker( can't get value of input)

前端 未结 7 1722
名媛妹妹
名媛妹妹 2021-02-20 06:25

I am new in react. I need use react-datepicker

I want to get value of input, when I change date. If i click on 20th October 2017, i want put 20th October 2017 in my vari

相关标签:
7条回答
  • 2021-02-20 07:10

    This solved for me by using the following:

    handleDateChange = date => {
    let selectedDateFromCalender = date.toUTCString();
    this.setState({
          actualStartDate: selectedDateFromCalender,
      });}
    
    <DatePicker
    selected={this.state.startDate}
    onChange={this.handleDateChange}/>
    

    You can use the following methods as well, choose according to your requirement:

    toISOString: "2020-10-05T09:10:38.000Z"

    toJSON: "2020-10-06T09:09:16.000Z"

    toUTCString: "Thu, 08 Oct 2020 09:11:24 GMT"

    0 讨论(0)
提交回复
热议问题