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.
- Prepare
- Algorithms
- Warmup
- Time Conversion
- Discussions
Time Conversion
Time Conversion
Sort by
recency
|
5163 Discussions
|
Please Login in order to post a comment
string timeConversion(string s) { string hour = s.substr(0, 2); // starts from 0 and len = 2 string amPM = s.substr(8); // from 0 to the rest
}
Java 15
Java Solution
Using a boolen value to indicate the time am/pm.
public static string timeConversion(string s) => DateTime.ParseExact(s, "hh:mm:sstt", CultureInfo.InvariantCulture).ToString("HH:mm:ss"); `
from datetime import datetime def timeConversion(s):
if name == 'main':