React encountered the problem of inaccurate acquisition time when using DatePicker of Antd

for example, if I choose 2018-05-01 , the date and time obtained by
in the background is 2018-05-01 02:08:17 this, not 2018-05-01 00:00:00

look up what seems to be the time zone on the Internet? I don"t know what to do in this case

Mar.11,2021

can't directly tell you what's wrong, but you can try opening the debug tool to see how much data is submitted to the server.


I think this is a problem with format format.

it returns a moment default format seems to be YYYY-MM-DD hh:mm:ss

this is what the official documentation on the time zone says:


Form getFieldDecorator

{getFieldDecorator("time", {
  initialValue: data.time ? moment(data.time, format) : undefined,
  type: [{type: 'object'}]
})(<TimePicker minuteStep={30} format={format} placeholder=""/>)}

you need to deal with the value when you submit:

this.props.form.validateFieldAndScrol(err, values) {
  if (!err) {
    axios.post(url, {
      time: values.time && values.time.format('HH:mm'),
    }).then(res => {

        ...
    })

  }
}
Menu