How to Convert Unix Timestamp to Date Format in PHP

To convert a Unix timestamp to a readable date format in PHP, use the native date() function. Pass the format you wish to use as the first argument and the timestamp as the second.


To demonstrate this, let's generate a new Unix timestamp using the PHP time() function then print the day/month/year and hours:minutes:seconds.


$stamp = time();

$date = date("d F Y H:i:s", $stamp);

08 June 2021 20:33:01


If you would like to understand PHP dates in more detail and the kinds of formatting that can be achieved, read my tutorial on how to use PHP DateTime() objects.