How can the DATE_FORMAT function in MySQL be used to format timestamps for display in PHP?

To format timestamps for display in PHP using the DATE_FORMAT function in MySQL, you can retrieve the timestamp from the database and use the DATE_FORMAT function to format it according to your desired format. You can then display the formatted timestamp in your PHP code.

<?php
// Connect to MySQL database
$mysqli = new mysqli("localhost", "username", "password", "database");

// Retrieve timestamp from database
$result = $mysqli->query("SELECT DATE_FORMAT(timestamp_column, '%Y-%m-%d %H:%i:%s') AS formatted_timestamp FROM table_name");

// Display formatted timestamp
$row = $result->fetch_assoc();
echo $row['formatted_timestamp'];

// Close database connection
$mysqli->close();
?>