setISODate() to set ISO Date

Set a date from ISO week and weekday

setISODate() sets a date using ISO week-numbering year, week number and weekday. Monday is day 1 in ISO week notation.

$date = new DateTimeImmutable();
$changed = $date->setISODate(2026, 38, 1);
echo $changed->format('Y-m-d');

ISO week-numbering years can differ from the calendar year near the beginning and end of December/January.

date_isodate_set ($date_obj,$year, $week,$day);
ParameterDESCRIPTION
$date_objRequired : Input date object to be assigned new value.
$yearRequired: Year in 4 digit.
$weekRequired: week of the year , starting from 1st week as 1
$dayOptional: default value is 1 , offset from 1st day of the week
Output is dateTime object, FALSE on failure.

Object Oriented style

First day of 2nd week of the year 2019.
$date = new DateTime();
$date->setISODate(2019, 2);
echo $date->format('Y-m-d'); // Output is 2019-01-07
3rd day of 5th week of year 2019
$date = new DateTime();
$date->setISODate(2019, 5,3);
echo $date->format('Y-m-d'); // Output is 2019-01-30


10th day of 4th week of year 2019
$date = new DateTime();
$date->setISODate(2019, 4,11);
echo $date->format('Y-m-d'); // Output is 2019-01-31

Procedural style

$date = date_create();
date_isodate_set($date, 2019, 25);
echo date_format($date, 'Y-m-d');  // Output is 2019-06-17
With $day value ( Optional )
$date = date_create();
date_isodate_set($date, 2019, 25,5);
echo date_format($date, 'Y-m-d');  // Output is 2019-06-21
PHP Date Functions setDate() : Set date for date object Timestamp in PHP Displaying calendar for selection of date by user


Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer