PyDocs

Nav

Data Types

date.today

datetime

classmethod of date
  • date.today()
Current date or datetime.

Equivalent to fromtimestamp(time.time()).
1 Example
>>> import time
>>> import datetime as dt
>>> today = dt.date.today()
>>> today
datetime.date(2007, 12, 5)
>>> today == dt.date.fromtimestamp(time.time())
True
>>> my_birthday = dt.date(today.year, 6, 24)
>>> if my_birthday < today:
...     my_birthday = my_birthday.replace(year=today.year + 1)
...
>>> my_birthday
datetime.date(2008, 6, 24)
>>> time_to_birthday = abs(my_birthday - today)
>>> time_to_birthday.days
202
from the Python docs
See Also
No see-alsos for datetime/date.today
0 Notes
No notes for date.today