note 77182 added to ref.datetime

From: Date: Sun, 19 Aug 2007 00:19:38 +0000
Subject: note 77182 added to ref.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-129580@lists.php.net to get a copy of this message
I wanted to do something like "10 days 2 months 5 years ago" so i came up with this following function to help me get an array of the "ago" time. <?php function timeAgo($tzSince){ $years = floor($tzSince/(60*60*24*365)); if($years>=0){$tzSince = $tzSince - ($year*60*60*24*365);} $mths = floor($tzSince/(60*60*24*30)); if($mths>=0){$tzSince = $tzSince - ($mths*60*60*24*30);} $days = floor($tzSince/(60*60*24)); if($days>0){$tzSince = $tzSince - ($days*60*60*24);} $hours = floor($tzSince/(60*60)); if($hours>0){$tzSince = $tzSince - ($hours*60*60);} $minutes= floor($tzSince/(60)); if($minutes>0){$tzSince = $tzSince - ($minutes*60);} $sec= floor($tzSince); $Arr_Since = array( 'years' => $years, 'months' => $mths, 'days' => $days, 'hours' => $hours, 'minutes' => $minutes, 'seconds' => $sec ); return $Arr_Since; } ?> Used successfully in http://betapod.hellclanner.com/ ---- Server IP: 69.147.83.197 Probable Submitter: 202.156.12.10 (proxied: 222.165.25.57) ---- Manual Page -- http://www.php.net/manual/en/ref.datetime.php Edit -- https://master.php.net/note/edit/77182 Del: integrated -- https://master.php.net/note/delete/77182/integrated Del: useless -- https://master.php.net/note/delete/77182/useless Del: bad code -- https://master.php.net/note/delete/77182/bad+code Del: spam -- https://master.php.net/note/delete/77182/spam Del: non-english -- https://master.php.net/note/delete/77182/non-english Del: in docs -- https://master.php.net/note/delete/77182/in+docs Del: other reasons-- https://master.php.net/note/delete/77182 Reject -- https://master.php.net/note/reject/77182 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129580) next »