Web | This Site

Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# PHP Function date_isodate_set()

## Syntax

void date_isodate_set ( DateTime $object, int $year, int $week [, int $day] ) void DateTime::setISODate ( int $year, int $week [, int $day] )

## Definition and Usage

These functions sets the ISO date into the passed object.

The above two functions are equivalent and any of the functions can be used as shown below in the example.

## Paramters

Parameter | Description
--- | ---
object | Required. DateTime object
year | Required. Year of the date.
week | Required. Week of the date.
day | Optional. Day of the date.

## Return Value

Returns NULL on success or FALSE on failure.

## Example

Following is the usage of this function:

    <?php
       $dateSrc = '2005-04-19 12:50 GMT';
       $dateTime = date_create( $dateSrc);;
       # Now set a new date using date_isodate_set();
       date_isodate_set( $dateTime, 2000, 12, 12);
       echo "New Formatted date is ". $dateTime->format("Y-m-d\TH:i:s\Z");
       echo "<br />";

       # Using second function.
       $dateTime = new DateTime($dateSrc);
       $dateTime->setISODate( 1999, 10, 12);
       echo "New Formatted date is ". $dateTime->format("Y-m-d\TH:i:s\Z");
    ?>

This will produce following result:

    New Formatted date is 2000-03-31T12:50:00Z
    New Formatted date is 1999-03-19T12:50:00Z

Advertisement

Online Image Processing

Indian Baby Names