PHP Tutorial - PHP time() Function






PHP represents time as the number of seconds that have passed since January 1st 1970 00:00:00 GMT.

time() gets the current time in epoch format.

Syntax

PHP time() Function has the following syntax.

int time ( void )

Example

Gets the current time in epoch format


<?PHP
print time(); 
$CurrentTime = time(); 
print $CurrentTime; 
?>

For more precise time values, use the microtime() function.

The code above generates the following result.