JSFiddle - React, Tailwind, and code Playground
JavaScript
const s = '07:05:45PM';
const [hour, minute, second] = s.slice(0,8).split(':');
hour = s.includes('PM') ?
(hour == 12 ? '12' : Number(hour) + 12) :
(hour == 12 ? '00' : hour);
return `${hour}:${minute}:${second}`;