You are viewing a single comment's thread. Return to all comments →
function timeConversion(time12h) { const period = time12h.slice(-2); // "AM" or "PM" let [hour, minute, second] = time12h.slice(0, -2).split(':');
if (period === 'PM' && hour !== '12') { hour = String(parseInt(hour, 10) + 12); } else if (period === 'AM' && hour === '12') { hour = '00'; } return ``${hour.padStart(2, '0')}:$`{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 →
function timeConversion(time12h) { const period = time12h.slice(-2); // "AM" or "PM" let [hour, minute, second] = time12h.slice(0, -2).split(':');
}