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

search for in the

gmdate> <getdate
Last updated: Fri, 22 Aug 2008

view this page in

gettimeofday

(PHP 4, PHP 5)

gettimeofdayObtiene la hora actual

Descripción

mixed gettimeofday ([ bool $devolver_flotante ] )

Esta es una interfaz a gettimeofday(2). Devuelve una matriz asociativa que contiene los datos devueltos por la llamada de sistema.

Lista de parámetros

devolver_flotante

Cuando se define como TRUE, un valor flotante es devuelto en lugar de una matriz.

Valores retornados

Por omisión, un valor tipo array es devuelto. Si devolver_flotante es definido, entonces un valor float es devuelto.

Claves de la matriz:

  • "sec" - segundos desde el Epoch Unix
  • "usec" - microsegundos
  • "minuteswest" - minutos al oeste de Greenwich
  • "dsttime" - tipo de corrección de ahorro de luz diurna

Registro de cambios

Versión Descripción
5.1.0 El parámetro devolver_flotante fue añadido.

Ejemplos

Example #1 Ejemplo de gettimeofday()

<?php
print_r
(gettimeofday());

echo 
gettimeofday(true);
?>

El resultado del ejemplo seria algo similar a:

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
13-Feb-2005 08: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
12-Aug-1999 09: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, 22 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites