title: PHP Copy a file and rename with date and time
body: <p>How can I copy and rename a file from <code>Data/Results/result.txt</code> to <code>Data/Results</code> <code>History/2014-11-13-12-00_result.txt</code> ? My code isn't working.</p>
  
  <pre><code>$path = "Data/Results/"; // Upload directory
          $tpath = "Data/Results History/"; // Upload to History Folder
          $name = "result.txt";
          $source = $path.$name;
          $today = date("d-m-Y");
          $time = date("H-i-s");
          $newname = $today."_".$time."_".$name;
          $dest = $tpath.$name;
          copy($source,$dest);
          $rename = $tpath.$newname;
          rename($dest,$rename);
  </code></pre>