You can just do: $diff = date_create()->diff(new DateTime(“first day of January “.date(“Y”))); $hours = $diff->format(“%a”)*24 + $diff->h; As requested here’s a way to handle daylight savings: $transitions = (new DateTimeZone(date_default_timezone_get()))->getTransitions(); $thisYearsTransitions = array_values(array_filter($transitions, function ($v) { return substr($v[“time”],0,strlen(date(“Y”))) == date(“Y”); })); if (count($thisYearsTransitions) == 2 && date_create($thisYearsTransitions[0]) < date_create() && count($thisYearsTransitions)>0 && date_create($thisYearsTransitions[1]) > date_create()) … Read more