You are viewing a single comment's thread. Return to all comments →
JS version :
function timeConversion(s) { let amPm = s.slice(-2); let hours = parseInt(s.slice(0, 2)); let rest = s.slice(2, -2); if (amPm === 'PM' && hours !== 12) { hours += 12; } else if (amPm === 'AM' && hours === 12) { hours = '00'; } else if (hours < 10) { hours = '0' + hours; } return hours.toString().concat(rest); }
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 →
JS version :