Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

time

Returns the current timestamp.

Syntax

time(): int

Return value

intThe number of seconds since 1 January 1970.

Examples

A timestamp is a large integer:

<?php
 
echo time();

The time in an hour and in a week:

<?php
 
$now = mktime(12, 0, 0, 1, 30, 2025);
 
echo date('H:i', $now + 3600), "\n";
echo date('d.m.Y', $now + 7 * 24 * 3600);

Output:

13:00
06.02.2025

Notes

Timestamps are easy to compare and store. For complex date arithmetic DateTimeImmutable objects are more reliable.

See also

  • date — Formats a date and time.
  • strtotime — Turns a textual date description into a timestamp.

Related recipes

In the tutorial

  • Date and time — Working with dates in PHP — the date function, the DateTimeImmutable class, formats, adding to dates and the difference between them.

Thanks for reading!

Donate to the site — we work hard for you.