note 56766 added to function.time

From: Date: Wed, 14 Sep 2005 18:06:50 +0000
Subject: note 56766 added to function.time
Groups: php.notes 
Request: Send a blank email to php-notes+get-95179@lists.php.net to get a copy of this message
I still think there is an error in shazow's code Correct code: <?php else if($elapsedTime<(60*60*24*365*2)) {//if the given timestamp is less the 24 months ago, display MONTHS $elapsedString = round($elapsedTime/60/60/24/30, $roundTo) . " months"; }?> flawed code: <?php else if($elapsedTime<(60*60*24*365*2)) {//if the given timestamp is less the 24 months ago, display MONTHS $elapsedString = round($elapsedTime/60/60/24/12, $roundTo) . " months"; }?> to get months, we need to go from: 60 seconds->60 minutes->24 hours->30 days not like he did from 60 seconds->60 minutes->24 hours->12 days I had 5 month old messages being displayed as 17 months or something, due to this little error, be careful if you use this otherwise wonderful piece of code :) ---- Manual Page -- http://www.php.net/manual/en/function.time.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56766 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56766&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56766&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56766&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56766&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56766&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56766&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56766&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#95179) next »