- PHP

How to get Timestamp in PHP

Solution 1:

Use DateTime() and getTimestamp().

<?php 
  $now = new DateTime();
  echo $now->getTimestamp();  
?>

Solution 2:

Use time() function.

<?php 
  echo time();
?>

Solution 3:

Use $_SERVER[‘REQUEST_TIME’]

<?php 
  echo $_SERVER['REQUEST_TIME']
?>