Format Time
Format Time
Tags: Basics
Credit: CodingChallenge
Difficulty: Beginner
Type: Text
Category: Practice
Time Allowed: 5 s
Description:
Write a function that takes a time string in the format "HH:MM:SS" and returns it in 12-hour format with AM/PM. This problem is designed to help you practice time formatting
. The function should accept one parameter and return the formatted time as a string.
Constraints:
- The input will be a
string
representing time in 24-hour format "HH:MM:SS". - The function should
return
astring
representing the time in 12-hour format with AM/PM. - Use the
datetime
module.
Example:
- Input:
"14:30:00"
- Output: `"02:30:00 PM"
Test Case | Input | Expected Output |
---|---|---|
1 | "14:30:00" | "02:30:00 PM" |
2 | "00:00:00" | "12:00:00 AM" |
3 | "12:00:00" | "12:00:00 PM" |
4 | "23:59:59" | "11:59:59 PM" |
Leave a Comment
Please login to leave a comment.