Get the current date using date.today()
The today() method of date class under DateTime module returns a date object which contains the value of Today’s date.
Syntax: date.today()
Returns: Return the current local date.
Example:
Python3
# Import date class from datetime module from datetime import date # Returns the current local date today = date.today() print ( "Today date is: " , today) |
Output:
Today date is: 2019-12-11
Get current date using Python
Prerequisite: DateTime module
In Python, Date and Time are not data types of their own, but a module named DateTime can be imported to work with the date as well as time. Datetime module comes built into Python, so there is no need to install it externally. The DateTime module provides some functions to get the current date as well as time.