note 91864 added to function.time

From: Date: Tue, 30 Jun 2009 06:43:25 +0000
Subject: note 91864 added to function.time
Groups: php.notes 
Request: Send a blank email to php-notes+get-157684@lists.php.net to get a copy of this message
RETURNS time left from supplied date ex. '3 days ago' etc. Basic function <?php function _ago($tm,$rcs = 0) { $cur_tm = time(); $dif = $cur_tm-$tm; $pds = array('second','minute','hour','day','week','month','year','decade'); $lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600); for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]); $no = floor($no); if($no <> 1) $pds[$v] .='s'; $x=sprintf("%d %s ",$no,$pds[$v]); if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm); return $x; } ?> ---- Server IP: 92.48.74.199 Probable Submitter: 217.43.90.67 ---- Manual Page -- http://www.php.net/manual/en/function.time.php Edit -- https://master.php.net/note/edit/91864 Del: integrated -- https://master.php.net/note/delete/91864/integrated Del: useless -- https://master.php.net/note/delete/91864/useless Del: bad code -- https://master.php.net/note/delete/91864/bad+code Del: spam -- https://master.php.net/note/delete/91864/spam Del: non-english -- https://master.php.net/note/delete/91864/non-english Del: in docs -- https://master.php.net/note/delete/91864/in+docs Del: other reasons-- https://master.php.net/note/delete/91864 Reject -- https://master.php.net/note/reject/91864 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157684) next »