today() function of datetime.date class in Python

The date.today() function returns the current local date.It constructs a date, from the current timestamp using fromtimestamp() method of time class. The Python example uses both date.today() and date.fromtimestamp() methods to get the current local date and prints to the console.

Date Updated 11 Jul 2019 1 min read

Function Name

today

Function Signature

@classmethod today()

Return Value

Returns the current local date.

Function Overview

  • The method today() of the date class, returns the current local date. By local it means the system and its current time settings used.
  • To construct the date, the date.today() function makes use of the current time.
  • Note that the date.today()is a class method. Hence, it can be called using the class name date itself, rather using an instance of date class.

Example

python
import datetime

import time

# Using date.today()

todaysDate = datetime.date.today()

print("Today's date - Using date class:%s"%todaysDate)

# Using date.fromtimestamp()

todaysDate = datetime.date.fromtimestamp(time.time())

print("Today's date - Using time class:%s"%todaysDate)

Output

Output
Today's date - Using date class:2019-07-11

Today's date - Using time class:2019-07-11