• Notice regarding image hosts and attachments. See here.

Help with PHP date sorting...

Associate
Joined
18 Oct 2002
Posts
2,092
Location
Edinburgh
Im currently trying to sort my latest uploads by date, the method i have come up with seems very complex and im sure there must be an easier way of doing it.

This is what im displaying at the moment.
http://www.mattinglis.com/index.php?Pagename=Upload

I want to eventually sort the current year by month aswell but just the current year.

This is the complex code im using also note its not future proof which i would like.

Code:
array_multisort(
array_map( 'filemtime', $files ),
SORT_NUMERIC,
SORT_DESC,
$files
);

echo '<font size=+1><b>2009</b><br><br></font>';
foreach ($files as $filename) {
    $datesort = filemtime($filename);
    if (date('Y', $datesort) == "2009"){
    $sizeoffile = (filesize($filename)/1024);
    $dateoffile = date("d/m/Y",filemtime($filename));
    echo '<a href="http://www.mattinglis.com/'.$filename.'">'.$filename.'</a>   ---                <b>Filesize</b> :  '.number_format($sizeoffile, 2, '.', '').' KBytes  -----         <b>Modified</b> : '.$dateoffile.'<br>';
   }
}
....
//and so on
....


Can anyone help?
 
Back
Top Bottom