<p>I can't replicate your issue.</p>
<p>Here is my process:  I checked the sunset and sunrise times on your website:
<a href="https://sunrise-sunset.org/search?location=Saint+Michaels%2C+MD" rel="nofollow noreferrer">https://sunrise-sunset.org/search?location=Saint+Michaels%2C+MD</a></p>
<p>This gives me 5:50:51 AM</p>
<p>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)</p>
<p><a href="https://api.openweathermap.org/data/2.5/weather?lat=38.783611&amp;lon=-76.222222&amp;appid=e4f5007a981cbb489d250d468352fe21" rel="nofollow noreferrer">https://api.openweathermap.org/data/2.5/weather?lat=38.783611&amp;lon=-76.222222&amp;appid=e4f5007a981cbb489d250d468352fe21</a></p>
<p>This returns the sunrise time as  <code>&quot;sunrise&quot;: 1652608364</code></p>
<p>I converted this to a human readable date using the standard UNIX &quot;date&quot; program</p>
<pre><code>$ TZ=&quot;America/New_York&quot; date --date=&quot;@1652608364&quot;
Sun 15 May 05:52:44 EDT 2022
</code></pre>
<p>For validation I also checked <a href="https://www.timeanddate.com/sun/@4368380" rel="nofollow noreferrer">https://www.timeanddate.com/sun/@4368380</a>.  It gives sunrise as 05:52</p>
<p>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 &quot;Saint Michaels&quot;, or adjustments for elevation.</p>
<p>I conclude that there must be some error in your conversion from a UNIX time to clock time.</p>

CC BY-SA 4.0
2022-05-15T13:32:51.733Z
2022-05-15T13:32:51.733Z
James K
<p>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.</p>
<p>The first step is to find out which number is wrong.</p>
<p>The 8:09 PM looks about right. I chose nearby Baltimore MD and used <a href="https://in-the-sky.org/skymap.php?year=2022&amp;month=5&amp;day=13&amp;town=4347778" rel="nofollow noreferrer">in-the-sky.org' planetarium for Baltimore for May 13, 2022</a> and at 8:04 PM the Sun is just touching the horizon.</p>
<p>We'd expect it to be a few minutes earlier than St. Michaels since it's a big further north.</p>
<p>I think you have several ways to approach debugging your use of the API</p>
<ol>
<li>wrong location (though you said you've checked that) moving north from Baltimore to Bangor Maine gets you to roughly 7:45 PM.</li>
<li>wrong date; a few weeks, but not an exact month earlier can also get you to 7:45 PM</li>
<li>bad API</li>
<li>bad implementation</li>
<li>something else</li>
</ol>
<p><strong>note:</strong> <a href="https://astronomy.stackexchange.com/questions/49318/why-do-sunrise-sunset-times-for-a-given-location-vary-based-on-the-source-of-t/49327#comment108516_49318">@GregMiller's comment:</a></p>
<blockquote>
<p>It'd probably help to post the code, it is most likely you're either passing data in incorrectly, or misinterpreting the result.</p>
</blockquote>
<p><a href="https://i.sstatic.net/bGdUr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bGdUr.png" alt="screenshot of in-the-sky.org's planetarium feature for around sunset in Baltimore MD. USA on May 13, 2022" /></a></p>
<p><a href="https://www.gaisma.com/en/location/baltimore-maryland.html" rel="nofollow noreferrer">Gaisma.com gives 8:11 PM for Baltimore</a></p>
<p><a href="https://i.sstatic.net/vckEe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vckEe.png" alt="screenshot of gaisma.com for Bangor ME. USA on May 13, 2022" /></a></p>
<p>But going north to Bangor Maine we can get to about 7:45 PM</p>
<p><a href="https://i.sstatic.net/LuWKg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LuWKg.png" alt="screenshot of in-the-sky.org's planetarium feature for around sunset in Bangor ME. USA on May 13, 2022" /></a></p>

CC BY-SA 4.0
2022-05-14T01:57:12.917Z
Horizons agrees. I get sunset for that location is ~2022-May-13 00:08 UTC, local sundial time = 19.1124 = 19:07
PM 2Ring
CC BY-SA 4.0
2022-05-14T02:07:29.483Z
https://ssd.jpl.nasa.gov/api/horizons.api?format=text&MAKE_EPHEM=YES&COMMAND=10&EPHEM_TYPE=OBSERVER&CENTER=coord%40399&COORD_TYPE=GEODETIC&SITE_COORD=%27-76.222222%2C38.783611%2C0.030%27&START_TIME=%272022-May-12+23%3A55%27&STOP_TIME=%272022-May-13+0%3A15%27&STEP_SIZE=1m&QUANTITIES=%274%2C13%2C34%27&REF_SYSTEM=ICRF&CAL_FORMAT=BOTH&TIME_DIGITS=SECONDS&ANG_FORMAT=DEG&APPARENT=REFRACTED&CSV_FORMAT=YES&OBJ_DATA=NO
PM 2Ring
CC BY-SA 4.0
2022-05-16T00:12:14.510Z
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
CC BY-SA 4.0
2022-05-16T00:19:00.567Z
@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)?](https://apple.stackexchange.com/q/437793/143729)
uhoh
CC BY-SA 4.0
2022-05-14T01:23:21.977Z
2022-05-15T01:44:49.923Z
2022-05-15T01:44:49.923Z
uhoh
<p>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?)</p>
<p>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.</p>

CC BY-SA 4.0
2022-05-14T01:43:18.107Z
@GregMiller examples have now been supplied, voting to leave open!
uhoh
CC BY-SA 4.0
2022-05-14T01:52:45.840Z
Which "today" do you mean? According to [Wikipedia](https://en.wikipedia.org/wiki/Saint_Michaels,_Maryland), St Michaels is in the UTC-5 time zone. Is Daylight Saving Time currently in effect there? Sunset for that location currently occurs near midnight UTC, so it's a Good Idea to be specific about which day we're actually talking about. ;)
PM 2Ring
CC BY-SA 4.0
2022-05-14T02:50:27.180Z
It'd probably help to post the code, it is most likely you're either passing data in incorrectly, or misinterpreting the result.
Greg Miller
CC BY-SA 4.0
2022-05-15T01:45:38.727Z
@GregMiller that is such an excellent suggestion I've quoted you in my answer as well.
uhoh
CC BY-SA 4.0
2022-05-13T01:35:02.600Z
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.
JohnHoltz
CC BY-SA 4.0
2022-05-13T04:57:38.940Z
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.
James K
CC BY-SA 4.0
2022-05-13T11:21:20.280Z
Another possibility is places with hills or mountains that some sites account for but others do not.
David Hammen
CC BY-SA 4.0
2022-05-13T12:00:00.463Z
WAG: you're checking two places with similar or identical names, such as Portland Oregon and Portland Maine.
Barry Carter
CC BY-SA 4.0
2022-05-13T14:54:45.823Z
Please provide examples.  It is possible near the poles for a 25 minute difference to be "normal".  As some algorithms will use the center of the sun, the top edge of the sun, and may or may not account for atmospheric refraction, or may use different refraction algorithms.  And any combination of those.
Greg Miller
<weather><sunrise><sunset>
Why do sunrise/sunset times (for a given location) vary based on the source of the data?
ETL
# Why do sunrise/sunset times (for a given location) vary based on the source of the data?

(Asked by: username_0 on 2022-05-12)

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.

**Tags:** weather, sunrise, sunset

> **Comments:**
> **username_4**: 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.  
> **username_5**: 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.  
> **username_6**: Another possibility is places with hills or mountains that some sites account for but others do not.  
> **username_7**: WAG: you're checking two places with similar or identical names, such as Portland Oregon and Portland Maine.  
> **username_3**: Please provide examples.  It is possible near the poles for a 25 minute difference to be "normal".  As some algorithms will use the center of the sun, the top edge of the sun, and may or may not account for atmospheric refraction, or may use different refraction algorithms.  And any combination of those.  
> **username_1**: @username_3 examples have now been supplied, voting to leave open!  
> **username_2**: Which "today" do you mean? According to [Wikipedia](https://en.wikipedia.org/wiki/Saint_Michaels,_Maryland), St Michaels is in the UTC-5 time zone. Is Daylight Saving Time currently in effect there? Sunset for that location currently occurs near midnight UTC, so it's a Good Idea to be specific about which day we're actually talking about. ;)  
> **username_3**: It'd probably help to post the code, it is most likely you're either passing data in incorrectly, or misinterpreting the result.  
> **username_1**: @username_3 that is such an excellent suggestion I've quoted you in my answer as well.  

---

## 2 answers

### Answer by username_5 on 2022-05-15. Score: 2 | Accepted answer

I can't replicate your issue.

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.


---

### Answer by username_1 on 2022-05-14. Score: 2

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](https://in-the-sky.org/skymap.php?year=2022&month=5&day=13&town=4347778) 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
3. bad API
4. bad implementation
5. something else

**note:** [@username_3's comment:](https://astronomy.stackexchange.com/questions/49318/why-do-sunrise-sunset-times-for-a-given-location-vary-based-on-the-source-of-t/49327#comment108516_49318)

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

[![screenshot of in-the-sky.org's planetarium feature for around sunset in Baltimore MD. USA on May 13, 2022](https://i.sstatic.net/bGdUr.png)](https://i.sstatic.net/bGdUr.png)

[Gaisma.com gives 8:11 PM for Baltimore](https://www.gaisma.com/en/location/baltimore-maryland.html)

[![screenshot of gaisma.com for Bangor ME. USA on May 13, 2022](https://i.sstatic.net/vckEe.png)](https://i.sstatic.net/vckEe.png)

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

[![screenshot of in-the-sky.org's planetarium feature for around sunset in Bangor ME. USA on May 13, 2022](https://i.sstatic.net/LuWKg.png)](https://i.sstatic.net/LuWKg.png)

> **Comments:**
> **username_2**: Horizons agrees. I get sunset for that location is ~2022-May-13 00:08 UTC, local sundial time = 19.1124 = 19:07  
> **username_2**: https://ssd.jpl.nasa.gov/api/horizons.api?format=text&MAKE_EPHEM=YES&COMMAND=10&EPHEM_TYPE=OBSERVER&CENTER=coord%40399&COORD_TYPE=GEODETIC&SITE_COORD=%27-76.222222%2C38.783611%2C0.030%27&START_TIME=%272022-May-12+23%3A55%27&STOP_TIME=%272022-May-13+0%3A15%27&STEP_SIZE=1m&QUANTITIES=%274%2C13%2C34%27&REF_SYSTEM=ICRF&CAL_FORMAT=BOTH&TIME_DIGITS=SECONDS&ANG_FORMAT=DEG&APPARENT=REFRACTED&CSV_FORMAT=YES&OBJ_DATA=NO  
> **username_0**: 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.  
> **username_1**: @username_0 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)?](https://apple.stackexchange.com/q/437793/143729)  

---

