RE: [PHP] directory timestamps - limiting by date

From: Date: Tue, 06 Aug 2002 03:36:58 +0000
Subject: RE: [PHP] directory timestamps - limiting by date
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-111328@lists.php.net to get a copy of this message
--- Martin Towell <martin.towell@world.net> wrote: > I think something like this could help (pseudo-code) > > function get_last_modified(directory) > mtime = 0 > fp = opendir(directory) > while (fname = readdir(fp)) !== false > new_mtime = mtime(directory + fname) > if new_mtime > mtime then mtime = new_mtime > end while > if now - mtime < 30 days > return time2string(mtime) > else > return "" > end function > > I'll leave the conversion from pseudo-code to php as > an exercise for you to > do.... :) > > HTH > Martin > hey thanks a bunch for the quick reply & helpful pointer! i'll admit though, while i do want to do this myself, i am slightly confused by parts of what you've posted.... i'm just getting started with php, so i guess a lot of things don't make sense yet (but i am trying!).... here's the code i've come up with so far: <?php $directory = './xyz'; function get_last_modified($directory) { $mtime = 0; $fp = opendir("$directory"); while (($fname = readdir($fp)) !== false) { $new_mtime = $mtime("$directory" + "$fname"); if ($new_mtime > $mtime) then ($mtime = $new_mtime); } #end while if now - mtime < 30 day { return time2string(mtime); else return "" end function ?> from the 'end while' bit down, i'm lost. i don't see anything about 'end while', 'now', or 'time2string' in the php manual. what are they exactly & how am i supposed to generate them? i mean, i understand what an 'end while' is supposed to be... the only syntax i could find for it for php is what i have above. i don't really know if it's right or not. anyway, the other things i have no idea at all about. any further pointers greatly appreciated. __________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com

« previous php.general (#111328) next »