I do not believe the file has an attribute of when it was created - it does have an attribute of when the file was last accessed and last written to (
PHP: fileatime - Manual and
PHP: filemtime - Manual ). The first thing that jumps out at me is to use a database. Store the file name, date it was created, and any other pertinent information regarding the image in the database. With SQL you can use ORDER BY on the date created column and you are pretty much done - you can even add a LIMIT 20 to only show 20 images. The other possibility is to store a timestamp as part of the images name: untitled-1213098600.jpg. Then just sort by the timestamp.