Date_sunrise () returns incorrect time and possibly result

There are two things that I do not understand about this function :

1. When used in the format SUNFUNCS_RET_TIMESTAMP is not taken into account. For example, if I use the SUNFUNCS_RET_STRING format and use this code:

$lat = 46.055556;    // Latitude (Ljubljana).
$long = 14.508333;    // Longitude (Ljubljana).
$offset = 2;    // Difference between GMT and local time in hours.
$zenith = 90 + 50 / 60;

echo "<br><p>Sunrise: " . date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);
echo "<br>Sunset: " . date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $long, $zenith, $offset);

Then it will somehow display the correct answer (by what I mean, I will somehow explain at the second point):

Sunrise: 05:15 Sunset: 20:42

Now, if I use SUNFUNCS_RET_TIMESTAMP and convert it to a string representation of a date with the date () function:

$lat = 46.055556;    // Latitude (Ljubljana).
$long = 14.508333;    // Longitude (Ljubljana).
$offset = 2;    // Difference between GMT and local time in hours.
$zenith = 90 + 50 / 60;

$dateSunRise = date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, $lat, $long, $zenith, $offset);
$dateSunSet = date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, $lat, $long, $zenith, $offset);

echo "<br><p>Sunrise: " . date("H:i", $dateSunRise);
echo "<br><p>Sunrise: " . date("H:i", $dateSunSet);

I get this result:

Sunrise: 03:15 Sunrise: 18:42

I checked the timestamp, and it will probably return incorrectly, so I don’t understand, because I have the same offset as in the previous example, where I used SUNFUNCS_RET_STRING.

2. , - , , . ARSO . (, ). , () :

: 5:18 : 20:41

date_sunrise date_sunset, :

: 05:15 : 20:42

, (, , , ). , , ( GeoHack ). , . , :

- 90+ (50/60) /

, , , ?

+3
1

, UNIX, , UTC. . , , SUNFUNCS_RET_STRING.

. 90+(50/60) - . -, , .

, :

$lat = 46.055556;    // Latitude (Ljubljana).
$long = 14.508333;    // Longitude (Ljubljana).
$offset = 2;    // Difference between GMT and local time in hours.

$rise_zenith = 90+(25/60);
$set_zenith = 90+(40/60);

echo "<br>Sunrise: " . date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $long, $rise_zenith, $offset);
echo "<br>Sunset: " . date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $long, $set_zenith, $offset);
+6

All Articles