Datetime¶

For working with dates and time in datetime there are types date, time, datetime, and timedelta. All of them are hashable and immutable.

In [ ]:
from datetime import date, time, datetime, timedelta

d: date = date(year=1964, month=9, day=2)
t: time  = time(hour=12, minute=30, second=0, microsecond=0, tzinfo=None, fold=0)
dt: datetime = datetime(year=1964, month=9, day=2, hour=10, minute=30, second=0)
td: timedelta = timedelta(weeks=1, days=1, hours=12, minutes=13, seconds=14)

print (f'{d}\n {t}\n {dt}\n {td}')
1964-09-02
 12:30:00
 1964-09-02 10:30:00
 8 days, 12:13:14