setISODate() to set ISO Date

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
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



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-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer