Skip to content
Related Articles
Open in App
Not now

Related Articles

PHP | date_isodate_set() Function

Improve Article
Save Article
  • Last Updated : 14 Sep, 2018
Improve Article
Save Article

The date_isodate_set() function is an inbuilt function in PHP which is used to sets the ISO (International Organization for Standardization ) date. This function set the date according to the ISO 8601 standard, using weeks and day offsets rather than specific dates.


  • Procedural style:
    date_isodate_set ( $object, $year, $week, $day )
  • Object oriented style:
    DateTime::setISODate ( $year, $week, $day )

Parameters: This function accepts four parameters as mentioned above and described below:

  • $object: This parameter is used in procedural style only. This parameter is created by date_create() function. The function modifies this object.
  • $year: This parameter is used to set year of the date.
  • $week:This parameter set the Week of the date.
  • $day: This parameter set offset from the first day of week.

Return Value: This function returns the DateTime object for method chaining on success or False on failure.

Below programs illustrate the date_isodate_set() function in PHP:

Program 1:

$date = date_create();
date_isodate_set($date, 2018, 9);
echo date_format($date, 'Y-m-d') . "\n";
date_isodate_set($date, 2018, 8, 17);
echo date_format($date, 'Y-m-d') . "\n";
date_isodate_set($date, 2018, 12, 23);
echo date_format($date, 'Y-m-d') . "\n";
date_isodate_set($date, 2015, 8, 24);
echo date_format($date, 'Y-m-d');



Program 2:

$date = new DateTime();
$date->setISODate(12, 05, 2018);
echo $date->format('d-m-Y') . "\n";
$date->setISODate(2018, 2, 27);
echo $date->format('Y-m-d') . "\n";



Related Articles:


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!