Get the newest file from directory structure year/month/date/time
- by Radek
I store backups of databases in a directory structure
year/month/day/time/backup_name
an example would be
basics_mini/2012/11/05/012232/RATIONAL.0.db2inst1.NODE0000.20110505004037.001 basics_mini/2012/11/06/012251/RATIONAL.0.db2inst1.NODE0000.20110505003930.001
note that timestamp from the backup file cannot be used. Before the automation testing starts the server time is set to 5.5.2011
So the question is how I can get the latest file if I pass the "base directory" (basics_mini) to some function that I am going to code. My thoughts are that I list the base directory and sort by time to get the year. Then I do the same for month, day and time.
I wonder if there is any "easier" solution to that in php.