php - [ solver } Sort gallery By date -


i have problem, created gallery works function sort images depends on day ignores mouths , minutes ... form used sort ::::: | d/m/y h:i:s |, when move mouth lose order because depends on day said want take in consideration mouth too.

 $date = date ("d/m/y h:i:s",filemtime($dir_mini));  function sortfunctionasc ( $a , $b ) { return strcmp($a["date"], $b["date"]); } 

and here give part sort gallery

//boucle sur le répertoire on extrait aussi le nom de l'image et de la miniature      $images = array();     while ( false !== ($fichier = readdir($ouverture)))      {                    $berk = array('.', '..');              $dir_mini = $dos_mini.$fichier;             $dir_img  = $dos_img.$fichier;             $img_name = $dir_mini ;              $img_name = preg_replace('#jpg|png|jpg|mini|/|\.#i', '',$img_name);             $date_precise = date ("d/f/y-h:i",filemtime($dir_mini));             $date = date ("d/m/y h:i:s",filemtime($dir_mini));               if(!in_array($fichier, $berk) , !is_dir($dir_mini) , !is_dir($dir_img) )              {                 $image = array();                 $image['date_precise']  = $date_precise;                 $image['date']  = $date;                 $image['img']   = $dir_img;                 $image['thumb'] = $dir_mini;                 $images[] = $image;              }        }        closedir($ouverture);     // cette deux fonctions trient les images en fonction de date  asc croissant, desc décroissant  function sortfunctionasc ( $a , $b ) { return strcmp($a["date"], $b["date"]); } function sortfunctiondesc( $b , $a ) { return strcmp($a["date"], $b["date"]); }  if (isset ($_get['asc']))  { usort ($images,"sortfunctionasc"); } if (isset ($_get['desc'])) { usort ($images,"sortfunctiondesc"); } if (!isset($_get['asc']) , !isset($_get['desc'])) { usort ($images,"sortfunctiondesc") ;} 

i think should convert date timestamp sorting. simple use filemtime ( string $filename ) without date ("d/m/y h:i:s"... stuff

function sortfunctionasc ( $a , $b ) { return $a["stamp"] < $b["stamp"]); } function sortfunctiondesc( $b , $a ) { return $a["stamp"] < $b["stamp"]); } 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -