This is a discussion on Re: date frustrations within the PHP General forums, part of the PHP Programming Forums category; The php manual says filemtime() returns a unix timestamp (does it do the same in a Windows environment?). I tried ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
The php manual says filemtime() returns a unix timestamp (does it do the
same in a Windows environment?). I tried the following snippet, and it seemed to work as expected: $dlist = array(); $handle = opendir($dir); while ($file = readdir($handle)) $dlist[$file] = filemtime($file); asort($dlist, SORT_NUMERIC); foreach($dlist as $name => $mtime) printf("%-30s\t%s\t%s\n", $name, $mtime, date("m/d/Y G:i",$mtime)); hth Kurt Milligan Shena Delian O'Brien wrote: > Ok so on a web application I needed to list the files in a directory, > ordered by last modified date. > > I was pulling them out in an array, fetching the filemtime() for each > file, and trying to order them by that date. I was using asort() to sort > the files in an array so they'd list chronologically. > > Well that wasn't working as planned. Files were getting out of order. I > figured asort() could have been having trouble ordering dates > numerically, so I tried strtotime() on the dates first, and ordered the > files by unix timestamp. > |
![]() |
| Thread Tools | |
| Display Modes | |
|
|