In the last example, conversion from seconds to Hour, Minutes, Seconds is wrong.
This is the correct verion:
<?php
$si = date_sun_info(strtotime('2022-08-26'), 50.45, 30.52);
$diff = $si['sunset'] - $si['sunrise']; # $diff is measured in seconds.
echo "Length of day: ",
floor($diff / 3600), "h",
floor(($diff % 3600) / 60), "m",
floor($diff % 60), "s\n";
?>
Output:
Length of day: 13h53m15s