Requirement: set the default time. When using defaultValue, the current time will be displayed. You need to set a defaultValue for the data in the first five minutes of the current time. Finally, it is found that simply setting defaultValue is problematic, and value and defaultValue need to be used together

StartTimes is five minutes before the current time, endTime is the current time, and DateFormat is the DateFormat

const DateFormat = 'YYYY-MM-DD HH:mm:ss'; <Form.Item label=" select date :"> <RangePicker defaultValue={[moment(startTime), moment(endTime)]} value={[moment(startTime), DateFormat), moment(endTime, DateFormat)]} showTime format={DateFormat} key={this.state.keyValue} onChange={this.test} /> </ form.item > // Get the first five minutes of the current time getNowFormatDate = () => { var date = new Date(); var seperator1 = '-'; var seperator2 = ':'; Var minutes = parseInt('5'); var interTimes = minutes * 60 * 1000; var interTimes = parseInt(interTimes); date = new Date(Date.parse(date) - interTimes); var month = date.getMonth() + 1; var strDate = date.getDate(); var hour = date.getHours(); var minutes = date.getMinutes(); var seconds = date.getSeconds(); if (month >= 1 && month <= 9) { month = '0' + month; } if (strDate >= 0 && strDate <= 9) { strDate = '0' + strDate; } if (hour >= 0 && hour <= 9) { hour = '0' + hour; } if (minutes >= 0 && minutes <= 9) { minutes = '0' + minutes; } if (seconds >= 0 && seconds <= 9) { seconds = '0' + seconds; } var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + ' ' + hour + seperator2 + minutes +  seperator2 + seconds; return currentdate; }; GetNowTimeFormatDate = () => {var date = new date (); date.setMinutes(3); var seperator1 = '-'; var seperator2 = ':'; Var interTimes = minutes * 60 * 1000; var interTimes = parseInt(interTimes); date = new Date(); var month = date.getMonth() + 1; var strDate = date.getDate(); var hour = date.getHours(); var minutes = date.getMinutes(); var seconds = date.getSeconds(); if (month >= 1 && month <= 9) { month = '0' + month; } if (strDate >= 0 && strDate <= 9) { strDate = '0' + strDate; } if (hour >= 0 && hour <= 9) { hour = '0' + hour; } if (minutes >= 0 && minutes <= 9) { minutes = '0' + minutes; } if (seconds >= 0 && seconds <= 9) { seconds = '0' + seconds; } var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + ' ' + hour + seperator2 + minutes +  seperator2 + seconds; return currentdate; };Copy the code

The final result is shown in figure;