In this video, Kathryn teaches you how to use the calendar module to get numerical information about past and upcoming dates. Learn how to compare dates and even generate a calendar right in your code. In addition, learn how to calculate on which day of the week a given date falls, and whether or not that year is a leap year.
- [Instructor] Now we can use the timedelta class…to get information about future and past times.…To get access to it, we're going to go comma timedelta,…and that's because the timedelta class lives…inside of the datetime module.…Say you have a test date that's two days from now.…You could go testDate as your variable…and then do now + timedelta (days=2)…so now testDate holds information…about the day two days from now.…We can also look at past dates.…
Say we do myFirstLinkedInCourse,…and say you took your first LinkedIn course three weeks ago.…You can go now - timedelta(weeks=3)…and because we're doing the subtraction sign here,…it's going to go in the past, and it's going to represent…three weeks ago.…Printing these out, we can go print(testDate)…and because testDate is a datetime instance,…we can go .date and then we can also print out…myFirstLinkedInCourse because this is also…an instance of dateTime.…
So we'll do that.…Seeing these dates, this is two days from now,…and this was three weeks ago.…We can also compare times.…
- Working with logical and comparison operators
- Getting a list of numbers with the range() and list() functions
- Using mathematical functions such as round(), abs(), and pow()
- Calculating a given input's length
- Importing and using the math module
- Reading a user's command-line arguments
- Getting the current time
- Formatting dates and times with datetime
- Creating a timer
- Using urllib to get content from the Internet
- Using the JSON module to decode content
Skill Level Intermediate
Learning the Standard PHP Librarywith David Powers3h 24m Intermediate
1. Python: What's Built-In?
2. Python: Math
3. Python: Input/Output
4. Python: Date & Time, HTML Parsing, and HTTP
- 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.