PHP function to count days in current year

Custom function cal_days_in_year($year)

<?php 
 function cal_days_in_year($year){
    $days=0; 
    for($month=1;$month<=12;$month++){ 
        $days = $days + cal_days_in_month(CAL_GREGORIAN,$month,$year);
     }
 return $days;
}
echo cal_days_in_year(2017);
?>
Output : 365

Leave a Reply

Your email address will not be published. Required fields are marked *