downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

gmdate> <getdate
Last updated: Fri, 06 Nov 2009

view this page in

gettimeofday

(PHP 4, PHP 5)

gettimeofdayObţine timpul curent

Descrierea

mixed gettimeofday ([ bool $return_float ] )

Aceasta este o interfaţă pentru gettimeofday(2). Ea întoarce un tablou asociativ ce conţine datele întoarse în rezultatul apelului funcţiei de sistem.

Parametri

return_float

Când este stabilit în TRUE, este întors un float în locul unui tablou.

Valorile întroarse

Implicit este întors un array. Dacă return_float este stabilit, este întors un float.

Cheile tabloului:

  • "sec" - secunde începând cu Epoca Unix
  • "usec" - microsecunde
  • "minuteswest" - minute de la Vest de Greenwich
  • "dsttime" - tipul ajustării la timpul de vară

Istoria schimbărilor

Versiunea Descriere
5.1.0 A fost adăugat parametrul return_float .

Exemple

Example #1 Exemplu gettimeofday()

<?php
print_r
(gettimeofday());

echo 
gettimeofday(true);
?>

Exemplul de mai sus va afişa ceva similar cu:

Array
(
    [sec] => 1073504408
    [usec] => 238215
    [minuteswest] => 0
    [dsttime] => 1
)

1073504408.23910



add a note add a note User Contributed Notes
gettimeofday
lucas dot karisny at linuxmail dot org
14-Feb-2005 02:26
A small improvement on getTimer.  Using vsprintf instead of sprintf there is no need to assign the array:

<?php
function utime()
{
  return (float) (
vsprintf('%d.%06d', gettimeofday()));
}
?>

In a test on my machine getTimer took 0.037519 seconds to run through 1000 iterations versus 0.027912 seconds for utime.  In total, utime runs about 25% quicker.  The use is negligible in an actual benchmarking scenario, but this could provide a slightly more accurate estimate.  Of course the time it takes to run the function could always be stored at the start and subtracted from your total value each time it is run.
middleto at pilot dot msu dot edu
13-Aug-1999 02:49
The types of DST correction (from sys/time.h on a Linux system):
 0     Not on DST
 1     USA DST
 2     Austrailian DST
 3     Western European DST
 4     Middle European DST
 5     Eastern European DST
 6     Canada DST
 7     Great Britain and Eire DST
 8     Rumania DST
 9     Turkey
10     Australian DST (with shift in 1986)

gmdate> <getdate
Last updated: Fri, 06 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites