i am creating a system and have problem with the function to convert year - year, month and date.
the thing that i understand is the year is round for 365 days, and others i am not really understand of all. can you give explanation for this function so that i can correct it? thank you.
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);
}
$a = "$year-$monthInt-$daysInt";
return $a;
}
$service_year_convert = year2monthsNdays($service_year);
$convert =explode('-',$service_year_convert);
$sl_year = $convert[0]; if($sl_year == NULL){$s_year = 0;} else{$s_year = $sl_year;}
$sl_month = $convert[1]; if($sl_month == NULL){$s_month = 0;} else{$s_month = $sl_month;}
$sl_day = round($convert[2]); if($sl_day == NULL){$s_day = 0;} else{$s_day = $sl_day;}
}