Date and Time in Python

Time and date manipulation is a common task in programming, and Python makes it easy.

Python provides a versatile set of tools for working with dates and times. Whether you need to calculate the difference between two dates, convert a date to a different format, or compare two dates, Python has the tools to help. Working with dates and times in Python can be tricky, but with the right knowledge, you can get the most out of the language. The Python standard library includes the datetime module, which provides convenient classes for working with dates and times. There are also several third-party libraries that handle more complex operations.

This series of tutorials will help you become a master of date and time manipulation in the realm of Python programming. The articles in the series are arranged in order from easy to difficult, from simple to complex, but if you have more or less experience working with Python before, you can start in whatever order you want.

1 Python: Convert Datetime to Timestamp and vice versa

2 How to Compare 2 Dates in Python

3 Python: How to Convert Date Strings into Date Objects

4 Python: How to subtract/add a period to a datetime object

5 Python: Calculate person’s age based on ISO 8601 date string birthday

6 How to Format Date and Time in Python

7 Python: 2 Ways to Check if a Date String is Valid

8 Python: Get the Current Date and Time with Timezone

9 Python: Get a list of all dates between 2 dates (3 ways)

10 Python: How to subtract/add a duration to a timestamp

11 Python: How to convert a datetime object to hex and vice versa

12 Python: How to Convert a Timestamp to a List of Bytes

13 Daylight Saving Time (DST) in Python: A Practical Guide (with Examples)

14 Python: How to Convert a Date String to a Timestamp

15 Python: Convert 24h time format to AM/PM format (and vice versa)

16 Python: How to get only date part from a datetime object

17 Python: How to check if 2 date ranges overlap (3 approaches)

18 3 Ways to Check Leap Year in Python

19 Grouping Dates by Year and Month in Python: A Comprehensive Tutorial

20 Python: Check if a date is between two other dates

21 Python: Get the day of the week based on a timestamp/datetime object

22 Python: Converting seconds to days/months/years

23 Python: Convert UTC Time to Local Time and Vice Versa

24 Python datetime program: Countdown to an event day in the future

25 Python: Sorting a list of user dicts by date of birth

26 Python: How to Loop Through a Range of Dates

27 Python datetime: ISO 8601 and RFC 3339 Conversion

28 Python: Encode datetime object to base64 string

29 Python: Truncate milliseconds from datetime string

30 Python: Find the Median Date Between Two Dates (3 Approaches)

31 Python: Generating a List of ‘datetime’ objects from a ‘calendar’ object

32 Python: Getting month/day name from number

33 How to display full year calendars in Python

34 Creating and Customizing Monthly Calendars in Python

35 Python: How to find the day of the week for any date (3 methods)

36 How to generate weekly calendars in Python

37 Python: How to List All Leap Years in a Given Range (3 Examples)

38 How to create HTML calendars with Python’s ‘calendar’ module

39 Python: How to create an interactive command-line calendar application

40 Python: How to calculate future US public holidays

41 Python: Create calendars and save to a CSV file

42 Python: Using type hints with datetime and timestamp

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments