note 114953 added to function.time
| From: | kotrakesh at gmail dot com | Date: | Mon, 05 May 2014 11:18:27 +0000 |
| Subject: | note 114953 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199414@lists.php.net to get a copy of this message | ||
simple ago function
function ago($time)
{
$periods = array("second", "minute", "hour", "day",
"week", "month", "year", "decade");
$lengths =
array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
$tense = "ago";
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference != 1) {
$periods[$j].= "s";
}
return "$difference $periods[$j] ";
}
----
Server IP: 72.52.91.14
Probable Submitter: 203.109.119.2
----
Manual Page -- http://php.net/manual/en/function.time.php
Edit -- https://master.php.net/note/edit/114953
Del: integrated -- https://master.php.net/note/delete/114953/integrated
Del: useless -- https://master.php.net/note/delete/114953/useless
Del: bad code -- https://master.php.net/note/delete/114953/bad+code
Del: spam -- https://master.php.net/note/delete/114953/spam
Del: non-english -- https://master.php.net/note/delete/114953/non-english
Del: in docs -- https://master.php.net/note/delete/114953/in+docs
Del: other reasons-- https://master.php.net/note/delete/114953
Reject -- https://master.php.net/note/reject/114953
Search -- https://master.php.net/manage/user-notes.php