Juniorrrrr
Juniorrrrr

Reputation: 169

How to change the time to the format with moment and datePicker AntD?

How to change the time to the format when the day is 23 o'clock. For example, when I click on 23 in the datapicker, 11 is shown, but i want to see 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")
);

Upvotes: 1

Views: 1527

Answers (1)

Omkar Kulkarni
Omkar Kulkarni

Reputation: 1215

Lowercase, i.e. 'h' or 'hh' is used for 12 hour format in momentjs.
Now since you want a 24 hour format, use 'H' or 'HH'. Use format="YYYY-MM-DD HH:mm:ss". This should work.

Upvotes: 3

Related Questions