PyDocs

Nav

Data Types

date

  • date(year, month, day)
Concrete date type.
Members of date

_

__format__
Formats self with strftime.
__str__
Return str(self).

c

ctime
Return ctime() style string.

d

day
Between 1 and the number of days in the given month of the given year.

f

fromisocalendar
Construct a date from the ISO year, week number and weekday.
fromisoformat
Construct a date from a string in ISO 8601 format.
fromordinal
Construct a date from a proleptic Gregorian ordinal.
fromtimestamp
Create a date from a POSIX timestamp.

i

isocalendar
Return a named tuple containing ISO year, week number, and weekday.
isoformat
Return string in ISO 8601 format, YYYY-MM-DD.
isoweekday
Return the day of the week represented by the date.

m

max
The latest representable date, date(MAXYEAR, 12, 31).
min
The earliest representable date, date(MINYEAR, 1, 1).
month
Between 1 and 12 inclusive.

r

replace
Return date with new specified fields.
resolution
The smallest possible difference between non-equal date objects, timedelta(days=1).

s

strftime
Format using strftime().
strptime
Parse string according to the given date format (like time.strptime()).

t

timetuple
Return time tuple, compatible with time.localtime().
today
Current date or datetime.
toordinal
Return proleptic Gregorian ordinal.

w

weekday
Return the day of the week represented by the date.

y

year
Between MINYEAR and MAXYEAR inclusive.
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
0 Notes
No notes for date