You are viewing a single comment's thread. Return to all comments →
Solution in JavaScript:
function timeConversion(s) { let timeArr = s.split(':') let hour = Number(timeArr[0]) let miliTime = s if (s[s.length - 2] === 'P' && hour !== 12) { hour += 12 miliTime = `${hour}:${timeArr[1]}:${timeArr[2]}` } else if (s[s.length - 2] === 'A' && hour === 12) { miliTime = `00:${timeArr[1]}:${timeArr[2]}` } return miliTime.slice(0, s.length - 2) }
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 →
Solution in JavaScript: