title: MySQL DATETIME shows correct date, but incorrect time (always midnight) in one table but not in another table?
body: <p>I am using MySQL's <code>DATETIME</code> to set the date and time in two different tables in a database (with PHP). One of these instances is in the <code>users</code> table and logs the time the person signs up for an account and when they last logged in. The other usage is in a separate <code>messages</code> table (within the same database) that logs when a user sends a message to another user.</p>
  <p>Although the MySQL <code>DATETIME</code> code is the same in each table, on the <code>messages</code> table it records the date, but the time the message was sent is always exactly midnight e.g. <code>2021-12-06 00:00:00</code></p>
  <p>In PHPmyAdmin I am using <code>DATETIME</code>, with no default value and not null in both tables.</p>
  <p>The PHP prepared statements for each usage are below. As you can see, where the data and time are needed I am using the <code>current_date</code> function.</p>
  <p><strong>EXAMPLE 1</strong> <code>users</code> table (time is recorded correctly in the database). Note: some of the variables such as <code>fname</code> are from form elements. I haven't included the form code to keep the code simpler.</p>
  <pre><code>$passwordHash = password_hash($pword, PASSWORD_DEFAULT);
  
  $sql = &quot;INSERT INTO lj_users 
              (firstname, lastname, email, username, password, 
              date_registered, last_login, active, profile_image, 
              permissions) 
          VALUES (:firstname, :lastname, :email, :username, :password, 
                  current_date, current_date, 0, '', 
                  'standard' )&quot;;
  
  $stmt = $connection-&gt;prepare($sql);
  
  $stmt-&gt;bindParam(':firstname', $fname);
  $stmt-&gt;bindParam(':lastname', $lname);
  $stmt-&gt;bindParam(':email', $email);
  $stmt-&gt;bindParam(':username', $uname);
  $stmt-&gt;bindParam(':password', $passwordHash);
  
  $stmt-&gt;execute();   
  </code></pre>
  <p><strong>EXAMPLE 2</strong> (time is NOT recorded correctly in the database)</p>
  <pre><code>$message_sql = &quot;INSERT INTO lj_messages 
                      (message_title, message_body, dm_recipient_id, 
                      dm_sender_id, message_date) 
                  VALUES (:message_title, :message_body, :dm_recipient_id, 
                          :dm_sender_id, current_date )&quot;;
  
  $stmt = $connection-&gt;prepare($message_sql);
  
  $stmt-&gt;bindParam(':message_title', $dm_title);
  $stmt-&gt;bindParam(':message_body', $dm_body);
  $stmt-&gt;bindParam(':dm_recipient_id', $dm_recipient_id);
  $stmt-&gt;bindParam(':dm_sender_id', $dm_sender_id);
  $stmt-&gt;execute();
  </code></pre>
  <p>I have absolutely no idea why this is happening.</p>