hi,
I'am writing a small function that calc how long estimate from day to day.
But that isn't so precise.
Any example for this ?
function range($period /* $start_time, $end_time */)
{
/* version 2*/
static $time_num = array(
'h' => 60,
'd' => 24,
'w' => 7,
'm' => 4,
'y' => 12,
);
static $time_unit = array(
'h' => 'Hours',
'd' => 'Days',
'w' => 'Weeks',
'm' => 'Month',
'y' => 'Years',
);
/* convert to base unit to minute */
$period = $period / 60;
/* version 2*/
$type = '';
foreach ($time_num as $key => $value)
{
if ($period > $value)
{
$period = $period / $value;
$type = $key;
}
else
break;
}
return $period . ' ' . format_string($type);
}
function format_string($unit)
{
/* version 2*/
static $time_unit = array(
'h' => 'Hours',
'd' => 'Days',
'w' => 'Weeks',
'm' => 'Month',
'y' => 'Years',
);
return isset($time_unit[$unit]) ? $time_unit[$unit] : $type;
}
Thanks
Regards,
Eric,
----------------------------------------------------
http://myprojects.srhost.info
eric{at}myprojects{dot}srhost{dot}info