9.3. Date#
9.3.1. Create a date#
9.3.1.1. Create any date#
import datetime
datetime.date(2021,7,24)
datetime.date(2021, 7, 24)
9.3.1.2. Create today’s date#
d=datetime.date.today()
d
datetime.date(2023, 3, 6)
If you want to specify timezone,use .now() instead of today()
Don’t add leading leading zeroes yourself, it will cause syntax error
9.3.1.3. When date is created, you will need to get its components too#
9.3.2. Get Date’s components#
d.year
2023
d.month
3
d.day
6
d.isoweekday
<function date.isoweekday>