Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python: Am trying to get time difference between y and x, it gives me -ve value in milliseconds. from datetime import datetime x = 2018-01-28
Python: Am trying to get time difference between y and x, it gives me -ve value in milliseconds. from datetime import datetime x = 2018-01-28 08:58:10.83 y = 2018-01-28 08:58:10.144 x_time = datetime.strptime(x, '%Y-%m-%d %H:%M:%S.%f') # 2018-01-28 08:58:10.830000 y_time = datetime.strptime(y, '%Y-%m-%d %H:%M:%S.%f') # 2018-01-28 08:58:10.144000 diff = y_time - x_time duration_milliseconds = round(diff.total_seconds() * 1000) print(duration_milliseconds) # -686
Result : -686
Expected: 61
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started