note 30591 added to function.time
| From: | hamdiggy at robotskull dot com | Date: | Sun, 23 Mar 2003 09:23:44 +0000 |
| Subject: | note 30591 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45671@lists.php.net to get a copy of this message | ||
this is probably already a function, but i thought i'd throw it in anyways. i just wrote this
to show how long ago a folder on my server had been updated.
here's the function:
function thatDate($time){
$time=time()-$time;
$days=$time/144000;
$hours=($time%144000)/6000;
$minutes=(($time%144000)%6000)/100;
$seconds=((($time%144000)%6000)%100);
$timestring='last updated [';
if(round($days)) $timestring.=round($days)."d ";
if(round($hours)) $timestring.=round($hours)."h ";
if(round($minutes)) $timestring.=round($minutes)."m";
if(!round($minutes)&&!round($hours)&&!round($days)) $timestring.="
".round($seconds)."s";
$timestring.=']';
return $timestring;
}
the argument it's looking for is the date the item was last changed. so you could call it with
something like this
echo thatDate(filectime('folder/folder/file'));
and it will output something like "last updated [1d 13h 24m]".
just make sure you give it a UNIX timestamp if you send it a time from a database or something.
hope somebody finds this useful.
--
http://www.php.net/manual/en/function.time.php
http://master.php.net/manage/user-notes.php?action=edit+30591
http://master.php.net/manage/user-notes.php?action=delete+30591
http://master.php.net/manage/user-notes.php?action=reject+30591