Change language

PHP DateTimeImmutable setTime () function

Syntax:
DateTimeImmutable DateTimeImmutable::setTime (int $hour, int  $minute, int $second, int $microseconds)
Parameters:This function takes four parameters as specified above and described below:
  • $hour:this parameter is used to set hours .
  • $minute:this parameter is used to set the minute time.
  • $second:this parameter is used to set a second time.
  • $microseconds:This parameter is used to set the time in microseconds.
Returns:This function returns a new date and time object.The following programs illustrate the DateTimeImmutable::setTime() function in PHP:Program 1:  
// PHP illustration program DateTimeImmutable::setTime()
// function 
// Create a new DateTimeImmutable() $datetimeImmutable = new DateTimeImmutable ( ’2019-10-04’ );  
// Initialize hour, minute and second $Hour = ’04’ ; $Minute = ’10’ ; $Second = ’40’ ;  
// Calling the DateTimeImmutable::setTime() function $a = $datetimeImmutable -> setTime ( $Hour , $Minute , $Second );  
// Get a new set of date and time in
// format ’ Ymd H: i: s ’ echo $a -> format ( ’Ymd H: i: s’ ); ?>
Exit:
2019-10 -04 04:10:40
Program 2:  
// PHP illustration program DateTimeImmutable::setTime()
// function 
// Create a new DateTimeImmutable() object $datetimeImmutable = new DateTimeImmutable ( ’2019-10-04’ );  
// Calling the setTime() function // with parameters such as 10 hour
// 33 minutes and 39 seconds $a = $datetimeImmutable -> setTime (10, 33, 39);  
// Get a new set of date and time in
// format ’ Ymd H: i: s ’ echo $a -> format ( ’Ymd H: i: s’ ); ?>
Exit:
2019-10 -04 10:33:39
Link: https: / /www.php.net/manual/en/datetimeimmutable.settime.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method