Will this work right?

From: Date: Fri, 13 Jun 2003 20:26:08 +0000
Subject: Will this work right?
Groups: php.general 
Request: Send a blank email to php-general+get-151420@lists.php.net to get a copy of this message
The following function converts minutes to years, monthes, weeks, days, hours, minutes. For instance, 61 minutes would become "1 hour, one minute". Before I use it, I want to make sure there are no stupid mistakes. I can't find any, can any of you? function min2ymwdhm($min){ $a = array(); $years = intval(intval($min) / 525600); if($years > 0) $array[] = $years . ' year' . ($years == 1 ? '' : 's'); $monthes = intval(intval($min) / 43200) % 12; if($monthes > 0) $array[] = $monthes . ' month' . ($monthes == 1 ? '' : 'es'); $weeks = intval(intval($min) / 10080) % 4; if($weeks > 0) $array[] = $weeks . ' week' . ($weeks == 1 ? '' : 's'); $days = intval(intval($min) / 1440) % 7; if($days > 0) $array[] = $days . ' day' . ($days == 1 ? '' : 's'); $hours = intval(intval($min) / 60) % 24; if($hours > 0) $array[] = $hours . ' hour' . ($hours == 1 ? '' : 's'); $minutes = intval($min) % 60; if($minutes > 0) $array[] = $minutes . ' minute' . ($minutes == 1 ? '' : 's'); return implode($array,', '); } -- 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 (#151420) next »