How to get the current Unix timestamp in PHP

The Unix timestamp represents the time measured in seconds since the start of the Unix epoch (January 1st, 1970). The Unix timestamp is often inserted into databases, to date the records.

Getting the Unix timestamp in PHP is done by using the time() function, which returns the current Unix timestamp of the server. Here we output the current Unix timestamp:

echo time();

And here we instert it into a sample database table:

mysql_query(“INSERT INTO MyTable(RowDate) VALUES(‘”.time().“‘)”);

Leave a Reply

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

Back To Top