Skip to content
PHP Logo

What is the function in PHP used to convert Unix time to a normal date and time?

To convert Unix time to a normal date and time in PHP, you can use the `date()` function along with the `strtotime()` function. `strtotime()` converts the Unix timestamp to a Unix timestamp, which can then be formatted using `date()` to display the date and time in a human-readable format.

php
$unixTime = 1609459200; // Unix timestamp to convert
$normalDateTime = date('Y-m-d H:i:s', $unixTime);
echo $normalDateTime; // Output: 2021-01-01 00:00:00