date_time_set


php apg

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



<?php

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

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

DateTime public DateTime::setTime ( int $hour , 
                                                         
int $minute , 
                                                         
int $second = 0 , 
                                                         
int $microsecond = 0 )


where,

$hour = The hour of the time

$minute 
= The minute of the time

$second 
= The second of the time

$microseconds 
= The microsecond of the time


?>

<?php

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

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

DateTime date_time_set ( DateTime $object , 
                                                  
int $hour , 
                                                  
int $minute , 
                                                  
int $second = 0 , 
                                                  
int $microsecond = 0 )


where,

$object =  A DateTime object returned by date_create

$hour 
= The hour of the time

$minute 
= The minute of the time

$second 
= The second of the time

$microseconds 
= The microsecond of the time

?>

 $object 


The DateTime object returned by date_create.



 $hour 


The $hour of the related time.



 $minute 


The $minute of the related time.



 $second 


The $second of the related time.



 $microsecond 


The $µsecond of the related time.





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
('Europe/Madrid');

$dttm001 = new DateTime('now');

$nwtm001 = $dttm001->setTime(8, 18, 32, 480000000);

echo 
$dttm001->format(DATE_COOKIE);

?> 

  2 EXERCISE   

<?php

date_default_timezone_set
('Europe/Madrid');

$dttm002 = date_create("now");

$nwtm002 = date_time_set($dttm002, 8, 18, 32, 480000000);

echo 
$dttm002->format('l, d-M-Y H:i:s T');

?>