Time Conversion

  • + 0 comments
        const am: number = s.search("AM")
        const pm: number = s.search("PM")
        const timeText: string[] = s.split(":")
        
        if (am > 0) {
            if (timeText[0] === "12") {
                return "00:"+timeText[1]+":"+timeText[2].slice(0,2)
            }else {
                return s.slice(0, am)
            }
        } else if (pm > 0) {
            return (timeText[0] === "12" ? timeText[0] : parseInt(timeText[0])+12)+":"+timeText[1]+":"+timeText[2].slice(0,2)
        }