React Datepicker( can't get value of input)

前端 未结 7 1586
名媛妹妹
名媛妹妹 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条回答
  •  旧时难觅i
    2021-02-20 06:53

    The new version of react-datepicker library stopped using a moment.js object, so here is my solution if you want to get a formatted string representation of the date.

    First import import format from "date-fns/format"; Then

        this.handleChange(format(value, "yyyy/MM/dd", { 
           awareOfUnicodeTokens: true }))}
           dateFormat="yyyy/MM/dd"
           selected={this.state.inputValue} otherProps={here} />
        ...
    

提交回复
热议问题