Advertisement
J2897

Time Difference

Feb 27th, 2022 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. from datetime import datetime as dt
  2.  
  3. recent_time = dt(1990, 12, 24)
  4. past_time = dt(1982, 7, 1)
  5. # recent_time = dt(1990, 12, 24, 00, 00, 00)
  6. # past_time = dt(1990, 11, 24, 00, 00, 00)
  7. print('Recent:', 1*'\t',recent_time)
  8. print('Past:', 2*'\t',past_time)
  9.  
  10. time_delta = recent_time-past_time
  11. print('Difference:', 1*'\t', time_delta)
  12.  
  13. minutes = time_delta.total_seconds() / 60
  14. print('Total minutes:', '\t', minutes)
  15.  
  16. hours = minutes / 60
  17. print('Total hours:', '\t', hours)
  18.  
  19. days = hours / 24
  20. print('Total days:', '\t', days)
  21.  
  22. weeks = days / 7
  23. print('Total weeks:', '\t', weeks)
  24.  
  25. months = weeks / 4
  26. print('Total months:', '\t', months)
  27.  
  28. years = months / 12
  29. print('Total years:', '\t', years)
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement