[PHP] gettimeofday()

gettimeofday() (funzione PHP) restituisce un array (o un decimale) con l’ora corrente.

tips&tricks

Sintassi

gettimeofday($decimale[facoltativo])
parametro descrizione
$decimale Valore booleano. Se viene indicato true, restituisce l’ora corrente sotto forma timestamp con decimale; in mancanza (default), restituisce un array

Esempi

print_r(gettimeofday());
echo gettimeofday(true); // 1521716683.3535
/* RISULTATO
Array
(
    [sec] => 1521716683
    [usec] => 320146
    [minuteswest] => -60
    [dsttime] => 0
)
*/
// [sec] - seconds since the Unix Epoch
// [usec] - microseconds
// [minuteswest] - minutes west of Greenwich
// [dsttime] - type of dst correction

echo date("d/m/Y", gettimeofday()["sec"]);
/* RISULTATO
22/03/2018
*/

Contenuti correlati

  • CSS
  • HTML
  • JavaScript
  • jQuery
  • PHP
  • SQL
  • WORDPRESS

Fonti esterne

funzioni php, php

Related Articles

0 Comment