You are viewing a single comment's thread. Return to all comments →
function timeConversion(s) { let hourIn24Format = ''; let [ hour, minute, second_meridiem ] = s.split(':'); let [ second, meridiem] = second_meridiem.split(/(?=[AP]M)/); if (meridiem == 'AM' && hour == '12') hourIn24Format = '00'; if (meridiem == 'PM' && hour < '12') hourIn24Format = 12 + parseInt(hour); return `${hourIn24Format || hour}:${minute}:${second}`; }
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 JavaScript Code