Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-08-20
Convert Unix Timestamp to Datetime in PHP

How to convert Unix timestamp to Datetime in PHP

🎈 🎈 🎈
+1

    $unixTimestamp = 1693468892;
    $date = date('Y-m-d H:i:s', $unixTimestamp);
    echo "Converted Date: " . $date;            
        

Output:
Converted Date: 2023-08-31 08:01:32
Example only. There may be multiple ways to perform this operation.

Code Explanation

In this PHP code, the Unix timestamp 1693468892 is passed to the date() function along with the format string 'Y-m-d H:i:s'.
The format string specifies that the output should be in the format YYYY-MM-DD HH:MM:SS. The date() function converts the Unix timestamp into this human-readable date and time format and the resulting date, in this case 2023-08-31 08:01:32, is then printed.


Other useful PHP date functions

Function Description Example
date() Formats a local date and time based on a given format string. date('Y-m-d H:i:s') returns 2024-08-28 12:34:56
time() Returns the current Unix timestamp (number of seconds since January 1, 1970). time() returns 1693227296
strtotime() Parses an English textual datetime description into a Unix timestamp. strtotime('2024-08-28 12:34:56') returns 1693227296
mktime() Returns the Unix timestamp for a date with specific time components (hour, minute, second, month, day, year). mktime(12, 34, 56, 8, 28, 2024) returns 1693227296
getdate() Returns an associative array with information about the current date/time or a given timestamp. getdate(1693227296) returns array with date components
gmdate() Formats a GMT/UTC date and time based on a given format string. gmdate('Y-m-d H:i:s', 1693227296) returns 2024-08-28 12:34:56
DateTime::createFromFormat() Creates a new DateTime object from a specified format. DateTime::createFromFormat('Y-m-d', '2024-08-28') returns DateTime object
DateTime::format() Formats a DateTime object according to a given format string. $datetime->format('Y-m-d H:i:s') returns 2024-08-28 12:34:56
DateTime::getTimestamp() Returns the Unix timestamp of a DateTime object. $datetime->getTimestamp() returns 1693227296
DateTime::setTimestamp() Sets the date and time based on a Unix timestamp. $datetime->setTimestamp(1693227296) sets the date/time to 2024-08-28 12:34:56
Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-08-20
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder