PHP copy file without changing the last modified date PHP copy file without changing the last modified date php php

PHP copy file without changing the last modified date


function copydt($pathSource, $pathDest) {   // copy(), same modification-time    copy($pathSource, $pathDest) or return FALSE;    $dt = filemtime($pathSource);    if ($dt === FALSE) return FALSE;    return touch($pathDest, $dt);}


Is there a way that a file can be copied without updating the last modified date??

Probably not, but you can use touch() to modify the time back to your desired value.


you can use filemtime() to get last modified date and then touch() for modifying last modified date/time