date_date_set


php apg

RESETS the current date of the DateTime object to a different date.



<?php

/* - - - - - - - - - - - - - - - - -

    Object oriented style
   
   - - - - - - - - - - - - - - - - - */

DateTime public DateTime::setDate int $year 
                                                         
int $month 
                                                         
int $day )


where,

$year The year of the date

$month 
The month of the date

$day 
The day of the date

?>

<?php

/* - - - - - - - - - - - - - - - - -

      Procedural style
   
   - - - - - - - - - - - - - - - - - */

DateTime date_date_set DateTime $object 
                                                  
int $year 
                                                  
int $month 
                                                  
int $day )


where,

$object A DateTime object

$year 
The year of the date

$month 
The month of the date

$day 
The day of the date

?>

 $object 


A DateTime object.



 $year 


The $year of the related date.



 $month 


The $month of the related date.



 $day 


The $day of the related date.





For Procedural style, only: A DateTime object returned by the function date_create.
The function modifies this object.

The DateTime object for method chaining or FALSE on failure.



  1 EXERCISE   

<?php

date_default_timezone_set
('Asia/Tokyo');

$dttm001 = new DateTime();

$year idate('Y');
$month idate('m');
$day idate('d');

$nwtm001 $dttm001->setDate($year$month$day);

echo 
$dttm001->format(DATE_W3C);

?> 

  2 EXERCISE   

<?php

date_default_timezone_set
('Asia/Tokyo');

$dttm002 date_create();

$year idate('Y');
$month idate('m');
$day idate('d');

$nwtm002 date_date_set($dttm002$year$month$day);

echo 
$dttm002->format('Y-m-d\TH:i:sP');

?>