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
Since the number of days is fixed in the other months, you just need to know how many days February has in $year:
$totalDaysInYear = date(‘z’, strtotime($year.’-12-31′))+1;