DateTimeImmutable::setISODate
Sets the ISO date
&reftitle.description;
public DateTimeImmutableDateTimeImmutable::setISODate
intyear
intweek
intdayOfWeek1
Returns a new DateTimeImmutable object with the date set according to the
ISO 8601 standard - using weeks and day offsets rather than specific dates.
&reftitle.parameters;
year
Year of the date.
week
Week of the date.
dayOfWeek
Offset from the first day of the week.
&reftitle.returnvalues;
&date.datetimeimmutable.return.modifiedobject;
&reftitle.examples;
DateTimeImmutable::setISODate example
&style.oop;
setISODate(2008, 2);
echo $date->format('Y-m-d') . "\n";
$date->setISODate(2008, 2, 7);
echo $date->format('Y-m-d') . "\n";
?>
]]>
&style.procedural;
]]>
&examples.outputs;
Values exceeding ranges are added to their parent values
setISODate(2008, 2, 7);
echo $newDate->format('Y-m-d') . "\n";
$newDate = $date->setISODate(2008, 2, 8);
echo $newDate->format('Y-m-d') . "\n";
$newDate = $date->setISODate(2008, 53, 7);
echo $newDate->format('Y-m-d') . "\n";
?>
]]>
&example.outputs;
Finding the month a week is in
setISODate(2008, 14);
echo $newDate->format('n');
?>
]]>
&examples.outputs;
&reftitle.seealso;
DateTimeImmutable::setDate
DateTimeImmutable::setTime