Join Joe Marini for an in-depth discussion in this video Using timedelta objects, part of Up and Running with Python.
A common scenario involving dates and times involves performing mathematical…operations on dates and times themselves. And you'll run into this for example when…you want to calculate the number of days until an event.…Or you want to find out when an expiration is going to be and we can use the time…deltas class in Python to help us with this.…And that's what we're going to look at in this particular lesson.…So I'm going to open up timedeltas_start.py.…And you can see that I've already imported some information about dates and times…from the Python library. So let's go back to snippets.…
So now what I'm going to do is import the Time Delta class.…I'm going to copy line 220, I'm going to paste that in here.…Okay so now I can use time delta information.…A time delta is basically a span of time. It's not a particular date.…It's not a particular time. It's a span of time and you can use this,…class, to perform time-based mathematics. So let's take a look at some examples.…Let's copy lines 222 and 223. All right.…
- Installing Python
- Choosing an editor/IDE
- Working with variables and expressions
- Writing loops
- Using the date, time, and datetime classes
- Reading and writing files
- Fetching Internet data
- Parsing and processing HTML
Skill Level Beginner
1. Preparing the Development Environment
2. Python Basics
3. Working with Dates and Times
4. Working with Files
5. Working with Web Data
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.