PHP 8.2.4 Released!


(PHP 4, PHP 5, PHP 7, PHP 8)

timeRetorna o timestamp Unix atual


time(): int

Retorna a hora atual medida no número de segundos desde a Era Unix (January 1 1970 00:00:00 GMT).


Exemplo #1 time() example

= time() + (7 * 24 * 60 * 60);
// 7 days; 24 hours; 60 mins; 60secs
echo 'Now: '. date('Y-m-d') ."\n";
'Next Week: '. date('Y-m-d', $nextWeek) ."\n";
// or using strtotime():
echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n";

O exemplo acima irá imprimir algo similar à:

Now:       2005-03-30
Next Week: 2005-04-06
Next Week: 2005-04-06



O timestamp do início da requisição está disponível na variável $_SERVER['REQUEST_TIME'] desde o PHP 5.1.

Veja Também

  • date() - Formatar um timestamp Unix
  • microtime() - Retorna um timestamp Unix com microsegundos

add a note

User Contributed Notes 1 note

r at rcse dot de
4 months ago
time() gives the timestamp of Greenwich Mean Time (GMT) which is defined as the official time for the whole earth. You get the local time by adding the time zone offset to this timestamp.
To Top