Change formatDate in datepicker of material ui

前端 未结 1 1125
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 00:24

i using material-ui datepicker component with redux form. It looks amazing by i have a little issue here. When i change the date it appears in my input field as yyyy-mm-dd.

相关标签:
1条回答
  • 2021-01-19 01:02

    As per DOC:

    formatDate ====> function ====> This function is called to format the date displayed in the input field, and should return a string.

    Signature: function(date: object) => any date: Date object to be formatted. returns (any): The formatted date.


    Receive the selected date as an argument of formatDate function, change the format of the date and return the formatter value as a string.

    Another change is:

    format(DD-MM-YYYY)
    

    DD-MM-YYYY should be a string like this:

    format('DD-MM-YYYY')
    

    Write it like this:

    <Field
          name="dateFrom"
          component={DatePicker}
          hintText="Ημερομηνία από"
          autoOk
          formatDate={(date) => moment(date).format('DD-MM-YYYY')}
    />
    
    0 讨论(0)
提交回复
热议问题