You are viewing a single comment's thread. Return to all comments →
const chunks = s.split(":"); let hours:number = parseInt(chunks[0]); let minutes: number = parseInt(chunks[1]); let secondChunk = chunks[2]; let second: number = parseInt(secondChunk.slice(0,2)); let format = secondChunk.slice(2); const standard = 12; if(format === "PM" && hours !== 12){ hours = standard + hours; }else if(format === "AM" && hours === 12) { hours = 0; } let result = ``${hours.toString().padStart(2,"0")}:$`{minutes.toString().padStart(2,"0")}:${second.toString().padStart(2,"0")}`; console.log(result); return result;
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 →