ID EN
Datetime

replace

Python 3.11

Return a date with the same value, except for those parameters given new values by whichever keyword arguments are specified.

Syntax

PYTHON
date.replace(year=self.year, month=self.month, day=self.day)

Examples

Example 1
PYTHON
>>> from datetime import date
>>> d = date(2002, 12, 31)
>>> d.replace(day=26)
datetime.date(2002, 12, 26)