Dates and times: date, time and datetime
Almost all real applications work with dates: orders, bookings, birthdays, logs. They look simple, but they have traps (months of…
Learn to work with dates and times in Python. In this lesson you will use the datetime module (date, time and datetime), date arithmetic with timedelta, formatting and parsing dates with strftime, strptime and the ISO format, the calendar module and weekdays, and time zones with their best practices, and apply it to computing differences between dates, ages, working days, durations and event schedules.
Almost all real applications work with dates: orders, bookings, birthdays, logs. They look simple, but they have traps (months of…
Adding 30 days to a date seems easy until you have to think about months of 28, 30 and 31 days and leap years. timedelta does all…
Dates inside the program are objects; outside (on screen, in files, in forms) they are text . Converting between both is a daily…
Many date problems need calendar data: how many days a month has, whether a year is a leap year, which day of the week a date…
When an application is used in several countries, "10:00" does not mean the same to everyone. Time zones are the most common…
Create a Python program that computes how many days there are between two dates using the datetime module. Subtracting two dates…
Create a Python program that tells which day of the week each date falls on. The weekday() method returns a number: 0 for Monday…
Create a Python program that adds (or subtracts) a number of days to a date using timedelta , and says which day of the week the…
Create a Python program that tells how many days a month has and whether the year is a leap year , using the calendar module.
Create a Python program that computes a person's age on a given date and how many days are left until their next birthday. The…
Create a Python program that shows each date in two readable formats . The strftime method converts a date into text following a…
Create a Python program that parses dates written as day/month/year and converts them to the standard ISO format, detecting the…
Create a Python program that computes the duration between two instants (date and time) and shows it in days, hours and minutes…
Create a Python program that counts the working days (Monday to Friday) between two dates, both included, going through the days…
Create a Python program that sorts events by date and time and computes the time elapsed between the first and the last. datetime…