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


plus2net.com






Post your comments , suggestion , error , requirements etc here .




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