Get the newest file from directory structure year/month/date/time

Posted by Radek on Stack Overflow See other posts from Stack Overflow or by Radek
Published on 2012-11-08T22:58:36Z Indexed on 2012/11/08 22:59 UTC
Read the original article Hit count: 251

Filed under:

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.

© Stack Overflow or respective owner

Related posts about php