简体   繁体   中英

How can I use date picker with time picker together?

I just want to use date picker with time picker together? just like the image below. 在此处输入图片说明

You can make use of react-datetime

In can use it like

handleDateChange = (dateObj) => {
        console.log(moment(dateObj).utc().format('YYYY-MM-DD HH:mm').toString());
    }
<Datetime dateFormat='YYYY-MM-DD' timeFormat='HH:mm' onBlur={this.handleDateChange.bind(this)}/> 

Datetime gives you a dateObj when you provide an event like onChange or onBlur on it. You can now using libraries like moment.js to manipulate the date and time format as you want

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM