# Why do sunrise/sunset times (for a given location) vary based on the source of the data?

I've noticed that different reputable weather websites will give different times for sunrise/sunset for the exact same location. I've seen variation by 25 minutes or more, for sunset on the same date at the same location, from two different websites. Assuming that they are all using the astronomical definition of sunset, is there any reasonable explanation for this variation? (e.g. Are there multiple accepted methods of calculating sunrise/sunset?)

Edit: The example I'm currently looking at is the Openweathermap API sunset time and the time given by sunrise-sunset.org, as an example. Looking at both for St. Michael's, Maryland (and having double-checked that I'm indeed looking at the same location for both), openweathermap shows 7:45pm, and sunrise-sunset.org shows 8:09pm, for sunset today. This town does not have an extreme longitude, and it is topographically pretty flat so I doubt one website is trying to account for horizon differences.

• A 25 minute difference is unexpected. Perhaps a minute or two depending on the calculation method.It would be helpful to know what websites and what location (latitude and longitude) you are checking. May 13 at 1:35
• My guess would be that some are listing the end of twilight, not sunset. But unless you mention the websites I think there could only be guesses. May 13 at 4:57
• Another possibility is places with hills or mountains that some sites account for but others do not. May 13 at 11:21
• WAG: you're checking two places with similar or identical names, such as Portland Oregon and Portland Maine. May 13 at 12:00
• It'd probably help to post the code, it is most likely you're either passing data in incorrectly, or misinterpreting the result. May 14 at 2:50

Here is my process: I checked the sunset and sunrise times on your website: https://sunrise-sunset.org/search?location=Saint+Michaels%2C+MD

This gives me 5:50:51 AM

Then I obtained a free API key from openweather and used 'postman' to request weather data for the location at a latitude/longitude of 38.783611, -76.222222 (These values from Wikipedia for Saint Michaels MD)

https://api.openweathermap.org/data/2.5/weather?lat=38.783611&lon=-76.222222&appid=e4f5007a981cbb489d250d468352fe21

This returns the sunrise time as "sunrise": 1652608364

I converted this to a human readable date using the standard UNIX "date" program

\$ TZ="America/New_York" date --date="@1652608364"
Sun 15 May 05:52:44 EDT 2022


For validation I also checked https://www.timeanddate.com/sun/@4368380. It gives sunrise as 05:52

There is a small discrepancy of less than a couple of minutes between these values. This is within the range that can be reasonably explained by differences in atmospheric models, different geolocations for "Saint Michaels", or adjustments for elevation.

I conclude that there must be some error in your conversion from a UNIX time to clock time.

They can't possibly be both correct, variations due to small differences in the center of the town's location or elevation will be seconds or a minute or so at most, so you need to go into debug mode.

The first step is to find out which number is wrong.

The 8:09 PM looks about right. I chose nearby Baltimore MD and used in-the-sky.org' planetarium for Baltimore for May 13, 2022 and at 8:04 PM the Sun is just touching the horizon.

We'd expect it to be a few minutes earlier than St. Michaels since it's a big further north.

I think you have several ways to approach debugging your use of the API

1. wrong location (though you said you've checked that) moving north from Baltimore to Bangor Maine gets you to roughly 7:45 PM.
2. wrong date; a few weeks, but not an exact month earlier can also get you to 7:45 PM
5. something else

It'd probably help to post the code, it is most likely you're either passing data in incorrectly, or misinterpreting the result.

Gaisma.com gives 8:11 PM for Baltimore

But going north to Bangor Maine we can get to about 7:45 PM

• Horizons agrees. I get sunset for that location is ~2022-May-13 00:08 UTC, local sundial time = 19.1124 = 19:07 May 14 at 1:57
• ssd.jpl.nasa.gov/api/… May 14 at 2:07
• I appreciate your help! I'm not directly using the API in my own code; it's used in my smartwatch's weather function. I'm guessing there's some issue with the app's code then. We'll, that's disappointing that the watch just doesn't do its job very well, I guess.
– ETL
May 16 at 0:12
• @ETL hmm... yes disappointing indeed! By the way, perhaps slightly related in Apple SE: I'd like to see the positions of the Moon and planets in the sky on my Apple watch. What are my options (if any)?
– uhoh
May 16 at 0:19