Are there best practices for inserting and updating date values in PHP scripts, specifically for forum posts?

When inserting or updating date values in PHP scripts for forum posts, it is best practice to use the current timestamp for new posts and to update the timestamp only when editing an existing post. This ensures that the date accurately reflects when the post was created or last modified.

// Inserting a new forum post with current timestamp
$currentTimestamp = date('Y-m-d H:i:s');
$query = "INSERT INTO forum_posts (content, created_at) VALUES ('$content', '$currentTimestamp')";

// Updating an existing forum post with current timestamp
$currentTimestamp = date('Y-m-d H:i:s');
$query = "UPDATE forum_posts SET content = '$content', updated_at = '$currentTimestamp' WHERE id = $post_id";