Re: Minutes to hours/days/monthes/years?

From: Date: Mon, 18 Nov 2002 05:23:33 +0000
Subject: Re: Minutes to hours/days/monthes/years?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-124871@lists.php.net to get a copy of this message
OK...I wrote this...is this what you want? return english_time("64925149"); function english_time($minutes) { while ($minutes>=525600) {$years++;$minutes-=525600;} while ($minutes>=1440) {$days++;$minutes-=1440;} while ($minutes>=60) {$hours++;$minutes-=60;} if ($years) { $string[] = ( $years == 1) ? "1 year" : "$years years"; } if ($days) { $string[] = ( $days == 1) ? "1 day" : "$days days"; } if ($hours) { $string[] = ( $hours == 1) ? "1 hour" : "$hours hours"; } if ($minutes) { $string[] = ( $minutes == 1) ? "1 minute" : "$minutes minutes"; } return implode(", ",$string); } "Leif K-Brooks" <eurleif@buyer-brokerage.com> wrote in message news:3DD81BD8.4090205@buyer-brokerage.com... > I'm looking for a good way to convert minutes to hours, days, or years - > the largest it will fit into. For example, 120 would become "2 hours". > 90 would become "1 hour and 30 minutes". Any ideas? > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. > >

« previous php.general (#124871) next »