In this tutorial, you shall learn how to get current timestamp in PHP using time() or microtime() functions, with example programs.

PHP – Get Current Timestamp

To get the current timestamp in PHP, we can use date/time functions.

In this tutorial, we will go through the following date/time functions to get the current timestamp.

  • time() – returns the current time as a Unix timestamp
  • microtime() – returns the current Unix timestamp with microseconds

Get Current Timestamp

time() function returns the current time in the number of seconds since Unix Epoch (1st Jan, 1970, 00:00:00 GMT).

PHP Program

</>
Copy
<?php
$timestamp = time();
echo $timestamp;
?>

Output