Syntax:DateTimeImmutable DateTimeImmutable::setISODate (int year, int week, int day))
Parameters:This function takes three parameters as above and described below:
- year:this parameter contains an integer year value.
- week:this parameter contains an integer week value.
- day:this parameter contains the day value in integer format.
Return values:this function returns a new date. The programs below illustrate the
DateTimeImmutable::setISODate()function in PHP:
Program 1:
// PHP illustration program DateTimeImmutabl e::setISODate()
// function
// Create a new DateTimeImmutable() object
$datetimeImmutable
=
new
DateTimeImmutable();
// Initialize the year, week and day
$Year
=
’2019’
;
$Week
=
’10’
;
$Day
=
’03’
;
// Calling the DateTimeImmutable::setISODate() function
$a
=
$datetimeImmutable
-> setISODate (
$Year
,
$Week
,
$Day
);
// Get a new set of dates in
// format ’ Ymd ’
echo
$a
-> format (
’ Ymd’
);
?>
Output:2019-03-06
Program 2:
// PHP illustration program DateTimeImmutable::setISODate()
// function
// Create a new DateTimeImmutable()
$datetimeImmutable
=
new
DateTimeImmutable();
// Calling the setISODate() function
// with parameters such as 2019
// week 9 and day 3
$a
=
$datetimeImmutable
-> setISODate (2019, 9, 03);
// Get a new set of dates in
// format ’ Ymd ’
echo
$a
-> format (
’ Ymd’
);
?>
Output:2019-02-27
Link: https://www.php.net/manual/en/datetimeimmutable.setisodate.php