Given two times
h2:m2 denoting hours and minutes in 24 hours clock format. The current clock time is given by
h1:m1. The task is to calculate the difference between two times in minutes and print the difference between two times in
Input : h1=7, m1=20, h2=9, m2=45
Output : 2 : 25
The current time is 7 : 20 and given time is 9 : 45.
The difference between them is 145 minutes.
The result is 2 : 25 after converting to h : m format.
Input : h1=15, m1=23, h2=18, m2=54
Output : 3 : 31
The current time is 15 : 23 and given time is 18 : 54.
The difference between them is 211 minutes.
The result is 3 : 31 after converting to h : m format.
Input : h1=16, m1=20, h2=16, m2=20
Output : Both times are same
The current time is 16 : 20 and given time is also 16 : 20.
The difference between them is 0 minutes.
As the difference is 0, we are printing “Both are same times”.
- convert both the times into minutes
- find the difference in minutes
- if difference is 0, print “Both are same times”
- else convert difference into h : m format and print
Below is the implementation.
2 : 25 3 : 31 Both are same times
- Python program to get Current Time
- Get current time in milliseconds using Python
- Get Current Date and Time using Python
- Get Current Time in different Timezone using Python
- Time Functions in Python | Set 1 (time(), ctime(), sleep()...)
- Python | How to time the program
- Python | time.time() method
- Python - Measure time taken by program to execute
- Python | Program to generate one-time password (OTP)
- Python program to convert time from 12 hour to 24 hour format
- Program to calculate the Round Trip Time (RTT)
- Python program to find sum of absolute difference between all pairs in a list
- How to find the current capacity of a list in Python
- Time tuple in Python
- time.sleep() in Python