React-datepicker: Timepicker 24-hour format in dropdown

Created on 16 Jun 2018  路  4Comments  路  Source: Hacker0x01/react-datepicker

Using timeFormat="HH:mm" changes the input field to the chosen format,

but in the dropdown the times are still in AM/PM format. I have gone through the docs multiple times but I do not see any other props to change the format than "timeFormat".

Example down below:
Input field is in 24 hour format,
Dropdown is in 12 hour format

Code snippet:
<DatePicker showTimeSelect showTimeSelectOnly dateFormat="HH:mm" timeIntervals={30} onChange={ e => handleDateChange(e) } />

example

Most helpful comment

Your example shows that you used dateFormat, which formats the input. You need to set the timeFormat to "HH:mm" too and this will format the dropdown.

All 4 comments

Your example shows that you used dateFormat, which formats the input. You need to set the timeFormat to "HH:mm" too and this will format the dropdown.

I can't believe that I missed that typo there! I have gone through the code so many times and somehow every time failed to see that I was using dateFormat prop.

Thank you!

Your example shows that you used dateFormat, which formats the input. You need to set the timeFormat to "HH:mm" too and this will format the dropdown.

Thanks alot! I couldn't seem to find a list with possible formats, where did you gather your information?

Your example shows that you used dateFormat, which formats the input. You need to set the timeFormat to "HH:mm" too and this will format the dropdown.

Thanks alot! I couldn't seem to find a list with possible formats, where did you gather your information?

Back when I answered this question the library was using moment.js, but now its using date-fns so you can find the formats here: https://date-fns.org/v1.28.5/docs/format

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hoodsy picture hoodsy  路  3Comments

flaurida picture flaurida  路  3Comments

ro-savage picture ro-savage  路  3Comments

pinturic picture pinturic  路  3Comments

jjjss94 picture jjjss94  路  3Comments