npm i react-time-picker
App.jsx
`
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import React, { useState } from 'react'; import TimePicker from 'react-time-picker'; import 'react-time-picker/dist/TimePicker.css'; import 'react-clock/dist/Clock.css'; const MyApp = () => { const [value, onChange] = useState('14:30'); // 2:30 PM return ( <div style={{ padding: '20px' }}> <h3>Select Time (24-hour format)</h3> <TimePicker onChange={onChange} value={value} format="HH:mm" // <-- This enforces 24-hour format disableClock={false} // Optional: show or hide the clock clearIcon={null} // Optional: hide clear button /> <p>Selected Time: {value}</p> </div> ); }; export default MyApp; |