Master Python's datetime type
Python's datetime
library, part of its standard library, provides datatypes and methods for working with dates and times. Dates and times are slippery, inconsistent things, however, and libraries for working with them can only smooth things over so much.
In this article, we'll explore how to use Python's datetime
library, its datatypes, and its methods. You'll learn how to make the most of these features while steering clear of their traps and complexities in Python.
datetime objects and namespacing
The name datetime
refers to both the datetime
library and to one of the Python datatypes. The library is namespaced as just datetime
. But the datatype for date-time objects is namespaced as datetime.datetime
.