Python Get Current Time
from datetime import datetime, time now = datetime.now()
1) Print Only Current Time
2) Print Hours Only
3) Print Minutes Only
4) Print Seconds Only
5) Print Microseconds
6) 12-Hour Format
7) Format HH:MM
HH:MM8) Format HH:MM:SS
HH:MM:SS9) Time With Milliseconds
10) Split Date & Time
11) Print Hour > 12?
12) Check AM or PM
13) Display Time in Words
14) Sleep and Show Updated Time
15) Time Comparison
16) Time in UTC
17) Print Local vs UTC
18) Time from User Input
19) Time Without Microseconds
20) Time Components as Variables
🧠 Concepts Practiced
Topic
Typical Method
📌 Quick Code Snippets
Last updated