【问题标题】:How to change the time to the format with moment and datePicker AntD?如何使用 moment 和 datePicker AntD 将时间更改为格式?
【发布时间】:2020-08-12 14:00:52
【问题描述】:

如何将时间更改为当天为 23 点的格式。例如,当我在数据选择器中单击 23 时,会显示 11,但我想看到 23

Code

function onChange(date, dateString) {
  console.log(date, dateString);
}

ReactDOM.render(
  <Space direction="vertical">
    <DatePicker
      allowClear
      placeholder="укажите дату"
      local="ISO 8601"
      showTime={{
        defaultValue: moment("00:00:00", "HH:mm:ss")
      }}
      format="YYYY-MM-DD hh:mm:ss"
      onChange={onChange}
    />
  </Space>,
  document.getElementById("container")
);

【问题讨论】:

    标签: javascript reactjs momentjs antd


    【解决方案1】:

    小写,即'h'或'hh'用于momentjs中的12小时格式。
    现在,由于您想要 24 小时格式,请使用“H”或“HH”。使用format="YYYY-MM-DD HH:mm:ss"。这应该可以。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多