note 106097 added to function.date

From: Date: Mon, 10 Oct 2011 02:15:29 +0000
Subject: note 106097 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-183761@lists.php.net to get a copy of this message
A smaller "time since incident" example that takes a datetime string as input : <?php function timesince( $tsmp ) { $diffu = array( 'seconds'=>2, 'minutes' => 120, 'hours' => 7200, 'days' => 172800, 'months' => 5259487, 'years' => 63113851 ); $diff = time() - strtotime($tsmp); $dt = '0 seconds ago'; foreach($diffu as $u => $n){ if($diff>$n) {$dt = floor($diff/(.5*$n)).' '.$u.' ago';} } return $dt; } ?> // example output: 10 seconds ago / 90 minutes ago / 16 months ago / 3 years ago ---- Server IP: 69.147.83.197 Probable Submitter: 86.164.49.222 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/106097 Del: integrated -- https://master.php.net/note/delete/106097/integrated Del: useless -- https://master.php.net/note/delete/106097/useless Del: bad code -- https://master.php.net/note/delete/106097/bad+code Del: spam -- https://master.php.net/note/delete/106097/spam Del: non-english -- https://master.php.net/note/delete/106097/non-english Del: in docs -- https://master.php.net/note/delete/106097/in+docs Del: other reasons-- https://master.php.net/note/delete/106097 Reject -- https://master.php.net/note/reject/106097 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183761) next »