DateTimeImmutable::setDate Sets the date &reftitle.description; #[\NoDiscard] public DateTimeImmutableDateTimeImmutable::setDate intyear intmonth intday Returns a new DateTimeImmutable object with the current date of the DateTimeImmutable object set to the given date. &reftitle.parameters; &date.datetime.description.modified; year Year of the date. month Month of the date. day Day of the date. &reftitle.returnvalues; &date.datetimeimmutable.return.modifiedobject; &reftitle.examples; <function>DateTimeImmutable::setDate</function> example &style.oop; setDate(2001, 2, 3); echo $newDate->format('Y-m-d'); ]]> &example.outputs; Values exceeding ranges are added to their parent values setDate(2001, 2, 28); echo $newDate->format('Y-m-d') . "\n"; $newDate = $date->setDate(2001, 2, 29); echo $newDate->format('Y-m-d') . "\n"; $newDate = $date->setDate(2001, 14, 3); echo $newDate->format('Y-m-d') . "\n"; ]]> &example.outputs; &reftitle.seealso; DateTimeImmutable::setISODate DateTimeImmutable::setTime