PHP Date_isodate_set () function

PHP

Syntax:
  • Procedural style:
    date_isodate_set ($object, $year, $week, $day) 
  • Object oriented style:
    DateTime::setISODate ($year, $week, $day)
  • Parameters:This function takes four parameters as above and described below:
    • $object:This parameter is only used in a procedural style. This parameter is created by the date_create() function. The function modifies this object.
    • $year:this parameter is used to set the year of the date.
    • $week:this parameter sets The week of the date.
    • $day:This parameter sets the offset from the first day of the week.
    Returned value:this function returns a DateTime object for chaining methods on success or False on error.The following programs illustrate the date_isodate_set() function in PHP:Program 1: $date = date_create(); date_isodate_set ( $date , 2018, 9); echo date_format ( $date , 'Ymd' ). "" ; date_isodate_set ( $date , 2018, 8, 17); echo date_format ( $date , 'Ymd' ). "" ; date_isodate_set ( $date , 2018, 12, 23); echo date_format ( $date , 'Ymd' ). "" ; date_isodate_set ( $date , 2015, 8, 24); echo date_format ( $date , 'Ymd' ); ?> Exit:
    2018-02 -26 2018-03-07 2018-04-10 2015-03-11
    Program 2: $date = new DateTime(); $date -> setISODate (12, 05, 2018); echo $date -> format ( 'dmY' ). "" ; $date -> setISODate (2018, 2, 27); echo $date -> format ( 'Ymd' ). "" ; ?> Exit:
    08-08 -0017 2018-02-03
    Related Articles:
    • PHP | Date_parse() function
    • PHP | Date_sunset() function
    • PHP | Date_sun_info() function
    Link: http://php.net/manual/en/datetime.setisodate.php



Get Solution for free from DataCamp guru