php8.5
Home/ Manual/ datetime / functions/ time

time

PHP function Edit on GitHub ✎

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

Return current Unix timestamp

Description

time(): int

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

Note

Unix timestamps do not contain any information with regards to any local timezone. It is recommended to use the DateTimeImmutable class for handling date and time information in order to avoid the pitfalls that come with just Unix timestamps.

Parameters Parameters

Return Values

Returns the current timestamp.

Examples

time() example

php
<?php
echo 'Now: '. time();

The above example will output something similar to:

output
Now: 1660338149

Notes

Tip

Timestamp of the start of the request is available in $_SERVER['REQUEST_TIME'].

See Also

Source: reference/datetime/functions/time.xml · from the official PHP manual (php/doc-en)