Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5967385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:56:11+00:00 2026-05-22T19:56:11+00:00

There are two things I do not understand about this function : 1.Offset not

  • 0

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

1.Offset not being taken into account when using in the format SUNFUNCS_RET_TIMESTAMP. For example if I use for the format SUNFUNCS_RET_STRING 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 display somehow correct answear (by what I mean somehow will explain in second point):

Sunrise: 05:15
Sunset: 20:42

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

$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 sure returns wrong, which is why I do not understand, because I have the same offset defined as in previous example where I used SUNFUNCS_RET_STRING.

2.In first point I have written, that it displays somehow correct answear, here is an explaination by what I mean by that. Our official meteorological agency ARSO updates daily on their pages the information about sunrise and sunset. The page can be found on this link (sorry, because it is not in english). Bottom line is, that for our capital city (Ljubljana) it has this information:

Sunrise: 5:18
Sunrise: 20:41

Where I get with date_sunrise and date_sunset function this:

Sunrise: 05:15
Sunset: 20:42

The parameters are the same as in first point (latitude, longitude, offset, zenith). Now the latitude and longitude are certainly correct (checked with GeoHack for Ljubljana). I am starting to think that this diffrence comes from zenith parameter. But I have searched on the internet and it says this:

The best Overall figure for zenith is 90+(50/60) degrees for true sunrise/sunset

I am clueless why it comes to this diffrence, is it possible that this two functions return wrong result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:56:11+00:00Added an answer on May 22, 2026 at 7:56 pm

    When you use timestamps, they’re almost always UNIX timestamps, which means they’re given in UTC. When working with them, you’ll have to convert them to your own timezone at the end of the calculation. For your purposes, you probably just want the SUNFUNCS_RET_STRING.

    For the second point, zenith plays a large part in calculating the exact minute of sunrise and sunset. The 90+(50/60) is just a ballpark estimate. There are calculators online which can give you better numbers to use for your coordinates, and they will be different for both sunrise and sunset.

    The following code will give you the numbers you’re looking for in Ljubljana:

    $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);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Although I do understand the serious implications of playing with this function (or at
Normally, I've seen prototype functions declared outside the class definition, like this: function Container(param)
I have a generic question about scope and encapsulation. Take two scenarios: Scenario 1:
This is someone elses code that I am trying to understand and modify... The
Hi again and welcome to another 'wouldn't it be great if we'd combine two
Disclaimer, I'm from a Java background. I don't do much C#. There's a great
Python has the idea of metaclasses that, if I understand correctly, allow you to
I've read a lot about NSDecimal, NSNumber, NSNumberDecimal, CFNumber... and it begins to be
Hey so i'm making a simple text game using the pdCurses library and a
I am trying to attach files in my RoR app. I am using Rails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.