Home >>PHP Date Time Functions >PHP time() Function

PHP time() Function

PHP time() Function

PHP time() function is used to get the current time measured in the number of seconds since the Unix Epoch. It does not accept any parameter value. It returns current time value which can be converted to the current date using date() function.

Syntax:

  time();

Here is an example of time() function in PHP:

<html>
<body>
<?php
echo time();
?>
</body>
</html>
Output:
1580711083

Example 2:

<html>
<body>
<?php
$t=time();
echo $t."<br>";  // time in number of seconds
echo date("Y-m-d H:i:s",$t);   // formated time
?>
</body>
</html>
Output:
1580711205
2020-02-03 06:26:45

No Sidebar ads