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.