Time Conversion

Sort by

recency

|

5159 Discussions

|

  • + 0 comments

    from datetime import datetime def timeConversion(s):

    a = datetime.strptime(s, "%I:%M:%S%p")
    return a.strftime("%H:%M:%S")
    

    if name == 'main':

    s = input()
    
    result = timeConversion(s)
    print(result)![](https://)
    
  • + 0 comments
    def ldec(n):
        return "{:02d}".format(n)
        
    def timeConversion(s):
        ampm = s[-2:]
        time = s[:-2].split(":")
        hours = int(time.pop(0))
        minutes = int(time.pop(0))
        seconds = int(time.pop(0))
        if (ampm == "PM" and hours != 12) or (ampm == "AM" and hours == 12):
            hours += 12
        return f"{ldec(hours%24)}:{ldec(minutes)}:{ldec(seconds)}"
    
  • + 0 comments

    python:

    ` def timeConversion(s): timeOfDay = s[8:] # count last two currentTime = s[:8] # get the rest if timeOfDay == 'PM' or currentTime.startswith("12"): if timeOfDay == 'AM': return currentTime.replace(currentTime[:2], "00") if currentTime.startswith("12"): return currentTime hourBefore12 = int(currentTime[:2]) hourAfter12 = hourBefore12 + 12 return(currentTime.replace(currentTime[:2], str(hourAfter12))) else: return currentTime

  • + 0 comments

    Locksmith Dewsbury services provide quick, reliable help during unexpected lockouts, ensuring your property remains secure and accessible. Just like mastering Time Conversion makes managing schedules easier, relying on a professional locksmith simplifies stressful situations with efficient solutions. From urgent door openings to repairing or upgrading security systems, skilled locksmiths deliver peace of mind. Their prompt, dependable service ensures that homes, businesses, and vehicles stay protected, offering trusted support whenever emergencies arise.

  • + 0 comments
    char* timeConversion(char* str) {
        int h,m,s;
        sscanf(str, "%d:%d:%d", &h, &m, &s);
        if (h == 12) h = 0;
        if (str[8] == 'P') h += 12;
        
        static char out[9];
        sprintf(out, "%02d:%02d:%02d", h, m, s);
        return out;
    }