How can PHP be used to automatically timestamp posts in a forum?

To automatically timestamp posts in a forum using PHP, you can use the `date()` function to generate the current timestamp when a post is submitted. This timestamp can then be stored in a database along with the post content. When displaying posts, you can retrieve the timestamp from the database and format it as needed for display.

// Assuming you have a database connection established

// Get the current timestamp
$timestamp = date('Y-m-d H:i:s');

// Insert the post content and timestamp into the database
$query = "INSERT INTO posts (content, timestamp) VALUES ('$postContent', '$timestamp')";
$result = mysqli_query($conn, $query);

// Display posts with timestamp
$query = "SELECT * FROM posts";
$result = mysqli_query($conn, $query);

while($row = mysqli_fetch_assoc($result)) {
    echo $row['content'] . " - " . $row['timestamp'] . "<br>";
}