I am trying to use the PHP function date_sun_infoto get the time information of certain sun positions during the day:
I am currently using code similar to the code in the documentation .
$sun_info = date_sun_info(strtotime('today'), 40.42, 74.0);
foreach ($sun_info as $key => $val) {
echo "$key: " . date("H:i:s", $val) . "<br>";
}
Output:
sunrise: 20:50:20
sunset: 07:45:03
transit: 02:17:41
civil_twilight_begin: 20:22:45
civil_twilight_end: 08:12:38
nautical_twilight_begin: 19:51:01
nautical_twilight_end: 08:44:22
astronomical_twilight_begin: 19:19:28
astronomical_twilight_end: 09:15:55
Which is clearly wrong.
I am not sure why this is happening. Any help would be greatly appreciated.
I thought it was related to time zones? If so, how can I fix this? The time zone for the server is set to America / New_York, which will be 5 hours behind GMT, but even so, the times may be wrong if I don't count on it wrong.
source
share