Are there any built-in PHP functions or libraries that can display time differences in a format similar to social media platforms?

To display time differences in a format similar to social media platforms, you can use the `DateTime` class in PHP along with the `DateTimeZone` class to calculate the time difference and format it accordingly. You can then create a function that takes a timestamp as input and returns the time difference in a user-friendly format like "just now", "5 minutes ago", "1 hour ago", etc.

function getTimeDifference($timestamp) {
    $now = new DateTime();
    $date = new DateTime("@$timestamp");
    $diff = $now->diff($date);

    if ($diff->y > 0) {
        return $diff->y . " year" . ($diff->y > 1 ? "s" : "") . " ago";
    } elseif ($diff->m > 0) {
        return $diff->m . " month" . ($diff->m > 1 ? "s" : "") . " ago";
    } elseif ($diff->d > 0) {
        return $diff->d . " day" . ($diff->d > 1 ? "s" : "") . " ago";
    } elseif ($diff->h > 0) {
        return $diff->h . " hour" . ($diff->h > 1 ? "s" : "") . " ago";
    } elseif ($diff->i > 0) {
        return $diff->i . " minute" . ($diff->i > 1 ? "s" : "") . " ago";
    } else {
        return "just now";
    }
}

// Usage example
$timestamp = 1625726000; // Example timestamp
echo getTimeDifference($timestamp);