We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Time Conversion
- Discussions
Time Conversion
Time Conversion
Sort by
recency
|
354 Discussions
|
Please Login in order to post a comment
I gone in a totally different way, with Python 3:
def timeConversion(s): return(datetime.datetime.strptime(s, "%I:%M:%S%p").time().strftime("%H:%M:%S"))
Go:
/* * Complete the 'timeConversion' function below. * * The function is expected to return a STRING. * The function accepts STRING s as parameter. */
func timeConversion(s string) string {
}
# Simple Java Solution | Easy to Understand
here's my 2 liner on python
!/bin/python3
import math def timeConversion(s): # Write your code here am_pm=s[-2:] hour=int(s[0:2]) min_sec=s[2:-2] if am_pm=="AM": if hour==12: hour=0 else: if hour!=12: hour+=12 return "{:02d}{}".format(hour,min_sec)
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')