How to select time with React DatePicker

空扰寡人 提交于 2020-12-10 13:19:10

问题


I'm using React Date Picker and I need also include time to the Date selection. I didn't find any example from documentation how to implement this. Does DatePicker provide any functionality for this out of box, or do I have to customize it myself?


回答1:


just add showTimeSelect

 <DatePicker
    selected={this.state.startDate}
    onChange={this.handleChange}
    showTimeSelect
    timeFormat="HH:mm"
    timeIntervals={15}
    dateFormat="LLL"
    />

check more examples @ reactdatepicker




回答2:


You can use react-date-picker module for a date with a timestamp. You can include the time by including timestamp in your dateFormat property.

E.g.: dateFormat="DD/MM/YYYY HH:mm:ss"

EDIT: Original links are not working anymore. Here's more information about react-date-picker. https://www.npmjs.com/package/react-date-picker

Original links:

http://zippyui.com/docs/react-date-picker/
https://github.com/zippyui/react-date-picker/



来源:https://stackoverflow.com/questions/38179473/how-to-select-time-with-react-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!