Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Antd RangePicker cannot set 12 hour format for Time

I am using Antd RangePicker for showing date range with Time.

By default, the time is the 24hr format. I need to show time in 12hr format. How can I set time in 12-hour format?

<RangePicker
    disabledDate={this.disabledDate}
    showTime={{
    format: 'HH:mm',
    hideDisabledOptions: true,
    defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('11:59:59', 
    'HH:mm:ss')],
    }}
    format="YYYY-MM-DD HH:mm:ss"
  />

I have tried options like:

use12Hours = {true}

But nothing worked for me. Please help.

like image 783
Neeraj narayanan Avatar asked Oct 16 '25 09:10

Neeraj narayanan


1 Answers

Ant Design uses momentjs and so you should be able to use the format: 'hh:mm' you may want to add an A, as in format: 'hh:mm A' in order to display the AM/PM time to ensure you do not confuse the person reading the time.

In addition to this you have FORMAT specified twice in your config.

You can read more about displaying times in momentjs here:

http://momentjs.com/docs/#/displaying/

like image 196
Vincro Avatar answered Oct 18 '25 03:10

Vincro