Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PHP Touch() using time() parameter for the past -any limitation?

When changing a file’s datetimestamp from the current system time to the distant past is there a limit with the time() parameter? With touch(), all the documentation I can see uses the time() parameter which has a future limitation of 100000 seconds:

 <?php
 $file_pointer = "gfg.txt";  
 // setting touch time to 5 hours in the past
 $time = time() - 18000;  
 // using touch() function to change the modification 
 // time of a file to current system time
 if (touch($file_pointer, $time)) 
 {
 echo ("$file_pointer modification time has been changed to 5 hours in the past.");
  } 
 else 
 {
 echo ("$file_pointer modification time cannot be changed.");
 }  
 ?>

What would be the best approach to change it to 1 year in the past or even 5 years in the past? Would the following be the most accepted approach and would it work?:

 $time = time() - 31536000;// 1 year
 $time = time() - 157680000;// 5 years 

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

use this docs

$time = strtotime("5 years ago");
// or
$time = strtotime("-5 years") 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading