gettimeofday


time apg

RETURNS the current time



<?php

arr
|float gettimeofday ([ bool $as_float = FALSE ] )


where,

$as_float = To control if the returned value will be
                                    a float number 
or an ARRAY

?>

 $as_float 


If $as_float = TRUE a float value is returned.

If $as_float = FALSE, (default), the returned value is an ARRAY.

In this case, we will have:

ARRAY KEYS MEANING
sec seconds since the Unix Epoch
usec microseconds
minuteswest minutes west of Greenwich
dsttime type of DST correction
ed48




See also the function microtime.



  1 EXERCISE   

<?php

$gttday01 
= gettimeofday();

// an array is returned

echo 'seconds since the Unix Epoch = ' . $gttday01['sec'];

echo 
'<br><br>microseconds = ' . $gttday01['usec'];

echo 
'<br><br>minutes west of Greenwich = ' . $gttday01['minuteswest'];

echo 
'<br><br>type of DST correction = ' . $gttday01['dsttime'];

?>

  2 EXERCISE   

<?php

$gttday02 
= gettimeofday(true);

// a float value is returned

echo 'The current time = ' . $gttday02;

?>

  3 EXERCISE   

<?php

setlocale
(LC_ALL, "en_US", "american", 
                   
"american english", 
                   
"american-english", 
                   
"english-american", 
                   
"english-us", 
                   
"english-usa", 
                   
"enu", "us", "usa"); 

$ddf03a = date_default_timezone_set('America/Los_Angeles'); 

$gttday03 = gettimeofday(TRUE);

echo 
$ddf03a . ':<br>' . $gttday03 . '<br><br>';

$ddf03b = date_default_timezone_set('UTC'); 

echo 
$ddf03b . ':<br>' . $gttday03 . '<br><br>';

?>