/**
* Function : year2monthsNdays
* Arguments : $years float value (Ex: 42.5, 30.89, 52.00, etc..)
* Returns : array (year,month,days as keys)
* Description: Converts a given float value of years to years, months and days
*/
function year2monthsNdays($years)
{
$array = explode(".",$years);
$year = $array[0];
$month = ($array[1]>9) ? $array[1]/100 : $array[1]/10;
if ($month) {
$days = round($month*365,2);
$daysArray = explode(".",$days);
$months = round($daysArray[0]/30,2);
$monthArray = explode(".",$months);
$monthInt = $monthArray[0];
$daysInt = round($monthArray[1]*30/100,1);
}
$returnArray['year'] = $year;
$returnArray['month'] = $monthInt;
$returnArray['days'] = $daysInt;
return $returnArray;
}
Related Articles
- Convert decimal to IEEE-754 in R (r-bloggers.com)
- Fraction Help: Converting to Decimal (brighthub.com)
- Winds of Plague Anticipating Intimate December Decimation Tour (noisecreep.com)
- Help with Decimals: Converting to Fraction (brighthub.com)
- You Can Do WHAT with the Windows 7 Calculator?! (itexpertvoice.com)
- Introducing the “Melvil Decimal System” ” The LibraryThing Blog (librarything.com)
- Teaching How to Calculate Math Percentages (brighthub.com)
- Funding cuts will ‘decimate’ 10 years of progress in school sport (guardian.co.uk)
- The Internet Needs a Dewey Decimal System (pcworld.com)
- How to Calculate Student Loan Monthly Payments (thinkup.waldenu.edu)
Advertisements
An amazing publish, I seriously discovered the topical i we do hope you can easily craft on this issue.
LikeLike