The PHP time() Function

The time( ) helps you to get the current time as  Unix timestamp.
Example :

<?php
/* Returning the current date and time 
*/
$timestamp = time();
echo($timestamp);
?>

Output :

1531546644

We can convert the timestamps to human redable date through passing it to the date() function .
Example:

<?php
/* Return current date and time from the remote server as timestamp */
$timestamp = time();
echo($timestamp);
echo "<br>";
//Converting timestamp to human readable format
echo(date("F d, Y h:i:s", $timestamp));
?>

Output :

1531548194
July 14, 2018 06:03:14

Leave a Reply

Your email address will not be published.Required fields are marked *