title: How to add date and time when a form is submitted in PHP?
body: <p>I am making a comment system in php which can store comment ,email and name of the user but I also want to add 2 fields more on my database called <em>time</em> - <em>date</em> that store the date and the time when user submitted the form automatically! I have searched a lot but I couldn't find any useful article about this. 
  If you can know how to do that please help me I would appreciate that!</p>
  
  <p>Here's my code: </p>
  
  <pre><code>&lt;form action='comment.php' method='POST'&gt;
      &lt;span&gt;
          &lt;input type='text' name='name' placeholder='Your Name'/&gt;
          &lt;input type='email' name='email' placeholder='Email Address'/&gt;
      &lt;/span&gt;
          &lt;textarea name='' name='comment' placeholder='Comment'&gt;&lt;/textarea&gt;
          &lt;input name='submit' type='submit' value='Submit'&gt;&lt;/input&gt;
          &lt;p&gt;&lt;?php if(isset($errors['name1'])) echo $errors['name1']; ?&gt;&lt;/p&gt;
          &lt;p&gt;&lt;?php if(isset($errors['name2'])) echo $errors['name1']; ?&gt;&lt;/p&gt;
          &lt;p&gt;&lt;?php if(isset($errors['email1'])) echo $errors['name1']; ?&gt;&lt;/p&gt;
          &lt;p&gt;&lt;?php if(isset($errors['email2'])) echo $errors['name1']; ?&gt;&lt;/p&gt;
          &lt;p&gt;&lt;?php if(isset($errors['comment1'])) echo $errors['name1']; ?&gt;&lt;/p&gt;
          &lt;p&gt;&lt;?php if(isset($errors['comment2'])) echo $errors['name1']; ?&gt;&lt;/p&gt;
  &lt;/form&gt;
  &lt;?php 
  $con = mysqli_connect("localhost","root","","ecommerce");
  if (isset($_POST['submit'])){
      $name = (isset($_POST['name']));
      $email = (isset($_POST['email']));
      $comment = (isset($_POST['comment']));
  
      if (empty($name)){
          $errors['name1'] = "&lt;p style='color:red;font-family: BCompset, Arial, Helvetica, sans-serif;font-size:30px;float:right;'&gt;Enter your name&lt;/p&gt;";
      }else{
          $name_length = strlen($name);
          if ($name_length &gt; 2 ){
              if (!empty($email)){
                      if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                      $errors['email1'] = "&lt;p style='color:red;font-family: BCompset, Arial, Helvetica, sans-serif;font-size:25px;float:right;'&gt;Enter your email&lt;/p&gt;"; 
                  }else{
                      if (empty($comment)){
                          $errors['comment1'] = "&lt;p style='color:red;font-family: BCompset, Arial, Helvetica, sans-serif;font-size:25px;float:right;'&gt;Write your comment&lt;/p&gt;"; 
                      }else{
                          $comment_length = strlen($comment);
                          if ($comment_length &lt; 5){
                              $errors['comment2'] = "&lt;p style='color:red;font-family: BCompset, Arial, Helvetica, sans-serif;font-size:25px;float:right;'&gt;Your comment must be more than 5 words&lt;/p&gt;"; 
                          }
                      }
                  }
              }else{
                  $errors['email2'] = "&lt;p style='color:red;font-family: BCompset, Arial, Helvetica, sans-serif;font-size:25px;float:right;'&gt;Enter your email&lt;/p&gt;"; 
              }
          }else{
              $errors['name2'] = "&lt;p style='color:red;font-family: BCompset, Arial, Helvetica, sans-serif;font-size:30px;float:right;'&gt;Your name must be more than 2 words/p&gt;";
          }
      }
  
      //check errors
          if(count($errors) == 0)
          {
              $insert_comment = "insert into comments (email,name,comment) values ('$email','$name','$comment')";
              $insert_comment = mysqli_query($con, $insert_comment);
          }
  }
  ?&gt;
  </code></pre>