Re: date frustrations

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-08-2003
Kurt Milligan
 
Posts: n/a
Default Re: date frustrations

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.
>


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:55 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0