You are viewing a single comment's thread. Return to all comments →
function timeConversion(s) { const meridiem = s.slice(-2); let [hour, min, sec] = s.slice(0,-2).split(":"); if(meridiem === "AM" && parseInt(hour) === 12) hour = "00"; if(meridiem === "PM" && parseInt(hour) !== 12 ) hour = parseInt(hour) + 12; return [hour, min, sec].join(":"); }
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
My solution in javascript
function timeConversion(s) { const meridiem = s.slice(-2); let [hour, min, sec] = s.slice(0,-2).split(":"); if(meridiem === "AM" && parseInt(hour) === 12) hour = "00"; if(meridiem === "PM" && parseInt(hour) !== 12 ) hour = parseInt(hour) + 12; return [hour, min, sec].join(":"); }