title: PHP Upload File with date and time
body: <p>I am using this function to upload the file
  How would I change the file name to: current date &amp; time for example. As any user that uploads a file, it's uploaded to the users ID file but with the name of there actual file, rather than the current date and time. For example: 14/09/02/18:32
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
      session_start();
  
  if(!isset($_SESSION["user"]) or !is_array($_SESSION["user"]) or empty($_SESSION["user"])) {
        // redirect to login page
  }
  
  
  
  $target_dir = ('users/'.$_SESSION["user"]["id"].'/');
  $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  $uploadOk = 1;
  $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  // Check if image file is a actual image or fake image
  
  
  // Check if file already exists
  
  // Check file size
  
  // Allow certain file formats
  if($imageFileType != "jpg" &amp;&amp; $imageFileType != "png" &amp;&amp; $imageFileType != "jpeg"
  &amp;&amp; $imageFileType != "gif" ) {
      echo "Sorry, only JPG, JPEG, PNG &amp; GIF files are allowed.";
      $uploadOk = 0;
  }
  // Check if $uploadOk is set to 0 by an error
  if ($uploadOk == 0) {
      echo "Sorry, your file was not uploaded.";
  // if everything is ok, try to upload file
  } else {
      if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
          echo header('Location: main.php');
      }
  }
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>:</p>