Back to Browse

Get minutes, hours, and days from Python timedelta - A Python Short by Michael Kennedy

7.4K views
Feb 11, 2022
6:44

Does it seem very strange that Python time deltas have a "total_seconds" but they don't have a total_minutes, or days, weeks, etc? Python does have an amazing solution for this, but it's incredibly non-obvious. Watch this short video and in 5 minutes you'll be amazed at how it works? Enjoy this Python short "quick hit" video by Michael Kennedy, a Python Software Fellow and host of the Talk Python To Me podcast. ▬ CODE ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Get the code for this video, and all my shorts, at https://talkpython.fm/shorts-code ▬ Chapters ▬▬▬▬▬▬▬▬▬▬▬▬ 0:00 - Introduction 0:45 - Setting the stage with the problem 2:06 - A little code to get us started 3:15 - From seconds to days and weeks (hard way) 3:33 - From timedelta to days and weeks (Pythonic way) 4:38 - From total floating-point days and weeks to combined days and weeks 6:27 - Conclusion ▬ More Videos ▬▬▬▬▬▬▬▬▬▬▬▬ Subscribe to the Python Shorts playlist by Michael at https://talkpython.fm/python-shorts to see all the topics we've covered. ▬ Dive deeper ▬▬▬▬▬▬▬▬▬▬▬▬ Listen to the Talk Python To Me podcast at https://talkpython.fm Check out our 100's of hours of Python courses at https://training.talkpython.fm/course... Follow Michael on Twitter at https://twitter.com/mkennedy

Download

1 formats

Video Formats

360pmp410.3 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Get minutes, hours, and days from Python timedelta - A Python Short by Michael Kennedy | NatokHD