1const convertTime12to24 = (time12h) => {
2 const [time, modifier] = time12h.split(' ');
3
4 let [hours, minutes] = time.split(':');
5
6 if (hours === '12') {
7 hours = '00';
8 }
9
10 if (modifier === 'PM') {
11 hours = parseInt(hours, 10) + 12;
12 }
13
14 return `${hours}:${minutes}`;
15}