<p>The time zone for the input to the equations is Universal Time (UT). The Universal Time is determined from the time on your clock (&quot;local time&quot;) and the time offset from UTC=0.</p>
<ul>
<li>UT is used to calculate the Julian Day (along with the date).</li>
<li>The Julian Day is used to calculate the Sun's ecliptic longitude. (This is then converted to right ascension and declination, assuming the Sun's ecliptic latitude is 0. :-)</li>
<li>The Julian Day (along with your longitude) is used to calculate your local sidereal time (LST).</li>
<li>The right ascension, declination, LST, and your latitude are used to calculate the altitude and azimuth.</li>
</ul>
<p>In summary, the input is the date and time (in UT), latitude and longitude. The output is the Sun's altitude and azimuth.</p>

CC BY-SA 4.0
2024-07-23T22:41:52.883Z
so I should convert the local time to UTC right? and is that equal to remove the offset from local time like if the local time = 15:23 and offset = +3 so the UTC = 12:23?
Ahmed Dyaa
CC BY-SA 4.0
2024-07-23T23:01:36.943Z
That is correct.
JohnHoltz
CC BY-SA 4.0
2024-07-24T00:14:31.460Z
Thanks @JohnHoltz, but why was local time converted to UTC in the equations in the website I mentioned in the question?
Ahmed Dyaa
CC BY-SA 4.0
2024-07-24T03:55:19.937Z
UT is used to make the equations easier. If they were based on the local time, you would need X number of different equations: one for each time zone. It is easier for everyone to use the same equation and let them convert their time to UT.
JohnHoltz
CC BY-SA 4.0
2024-07-24T04:46:36.667Z
And if I convert local time to UTC, will the altitude and azimuth values be accurate? I mean, sun altitude and azimuth would be correct at the local time of my choice? To clarify more, when I choose the time 11:23 as local time then converting it to UTC, it will be 8:23 and when calculating the altitude and azimuth then will these values be the same as the values of altitude and azimuth in my local time?
Ahmed Dyaa
CC BY-SA 4.0
2024-07-24T17:34:17.197Z
Yes. Alt and Az are based on the objects position (RA and Dec), sidereal time, and observer's location. The Sun's position is only correct when using UT. The sidereal time is correct when using UT because the calculation compensates for the time difference by using the longitude. Have you tried it yet? If not, why not? If so, did you get the correct result?
JohnHoltz
CC BY-SA 4.0
2024-07-26T02:10:22.473Z
Yes, I tried it and got the correct result, but I'm trying to deal with the local time and UTC in different time zones. I will add a property for time offset within (-11, 11) and add the value to local time hours. I think that will have the same effect as converting the time to UTC by time zone ID. Is that correct?
Ahmed Dyaa
CC BY-SA 4.0
2024-07-23T22:39:00.413Z
2024-07-23T22:39:00.413Z
JohnHoltz
<p>You should use <em>local</em> sideral time for calculations (again, I emphasize <em>local</em>, otherwise you will increase your work and over-complicate the entire process), then it is easy to convert the time you calculate into solar time then into other time zone like UTC+3</p>

CC BY-SA 4.0
2024-07-23T14:19:34.517Z
Unless you have a sundial or an app that tells you the local solar time, how do you know what the local solar time is?

I think the OP needs to clarify what is meant by "compute the Sun's position". If they are using equations, the equations are based on a particular time zone (probably UTC or TT). The time zone must match the time used by the computation method.
JohnHoltz
CC BY-SA 4.0
2024-07-23T14:21:57.507Z
@JohnHoltz, you calculate it through sidereal time which can be obtained by right ascension of the culminating celestial body
Polaris5744
CC BY-SA 4.0
2024-07-23T14:31:56.820Z
The equations are based on local sideral time (or hour angle if you prefer), not the solar time we use everyday.
Polaris5744
CC BY-SA 4.0
2024-07-23T15:22:28.090Z
I computed sidereal time at Greenwich then local sidereal time at the wanted longitude then local hour angle
Ahmed Dyaa
CC BY-SA 4.0
2024-07-23T16:04:35.210Z
You would use local sidereal time for computing the Alt/Az coordinates once you have RA/Dec coordinates.  Computing the RA/Dec coordinates would use something closer to TBD like UTC.  You'd also need something similar to UTC to compute the local sidereal time.
Greg Miller
CC BY-SA 4.0
2024-07-23T17:57:43.247Z
@AhmedDyaa I don't understand what you're asking. Sidereal time is almost always off by a number of minutes from the local time zone, and off from UTC by that same number of minutes plus the local time zone's offset. If you want to convert into either UTC or local clock-time, then you have to know that number of minutes and adjust your local sidereal to local time zone. You can then convert to UTC the usual way, if you want to.
Darth Pseudonym
CC BY-SA 4.0
2024-07-23T19:29:08.413Z
@GregMiller I have the local sidereal time, first I did that by computing ecliptic longitude of the Sun then converting the ecliptic longitude to right ascension and declination then I computed the sidereal time (degree) at Greenwich then local sidereal time at longitude then local hour angle then converting the hour angle and declination to altitude and azimuth
Ahmed Dyaa
CC BY-SA 4.0
2024-07-23T12:57:11.917Z
2024-07-23T14:32:47.553Z
2024-07-23T14:32:47.553Z
Polaris5744
<p>I'm trying to compute the sun's altitude and azimuth but should I convert the wanted local time to UTC by the time zone id? like in Saudi Arabia it uses <strong>AST</strong> (UTC +3 All the time) and Egypt uses <strong>EEST</strong> (UTC +3 In summer and In UTC +2 winter) or do I have to add the time difference manually?</p>
<p>Note: I followed this website to get the equations <a href="http://geoastro.de/elevaz/basics/index.htm" rel="nofollow noreferrer"> Basics of Positional Astronomy</a>.</p>

CC BY-SA 4.0
2024-07-23T14:42:05.217Z
What does *"compute the sun's position "* mean? Are you trying to calculate the Sun's RA (right ascension) and declination, or its ecliptic longitude? Or do you know the RA & declination and you're trying to calculate the Sun's azimuth and altitude (elevation) for your location?
PM 2Ring
CC BY-SA 4.0
2024-07-23T16:00:57.737Z
What time scale to use depends on the algorithms used.  The page you linked specifically has a step for converting to UT.  So your question could use some clarification if that doesn't answer it.
Greg Miller
CC BY-SA 4.0
2024-07-23T18:41:37.630Z
@GregMiller yes it has but I use datetime and my question is about should I convert local time to UTC too if I try to compute the sun's altitude and azimuth in Saudi Arabia?
Ahmed Dyaa
CC BY-SA 4.0
2024-07-23T19:27:13.033Z
@PM2Ring I mean compute the sun's altitude and azimuth and I did that by computing ecliptic longitude of the Sun then converting the ecliptic longitude to right ascension and declination then I computed the sidereal time (degree) at Greenwich then local sidereal time at longitude then local hour angle then converting the hour angle and declination to altitude and azimuth
Ahmed Dyaa
<the-sun><time>
Should I convert local time to UTC when computing the sun's position?
Ahmed Dyaa
# Should I convert local time to UTC when computing the sun's position?

(Asked by: username_0 on 2024-07-23)

I'm trying to compute the sun's altitude and azimuth but should I convert the wanted local time to UTC by the time zone id? like in Saudi Arabia it uses **AST** (UTC +3 All the time) and Egypt uses **EEST** (UTC +3 In summer and In UTC +2 winter) or do I have to add the time difference manually?

Note: I followed this website to get the equations  [Basics of Positional Astronomy](http://geoastro.de/elevaz/basics/index.htm).

**Tags:** the-sun, time
> **Comments:**
> **username_1**: What does *"compute the sun's position "* mean? Are you trying to calculate the Sun's RA (right ascension) and declination, or its ecliptic longitude? Or do you know the RA & declination and you're trying to calculate the Sun's azimuth and altitude (elevation) for your location?  
> **username_2**: What time scale to use depends on the algorithms used.  The page you linked specifically has a step for converting to UT.  So your question could use some clarification if that doesn't answer it.  
> **username_0**: @GregMiller yes it has but I use datetime and my question is about should I convert local time to UTC too if I try to compute the sun's altitude and azimuth in Saudi Arabia?  
> **username_0**: @PM2Ring I mean compute the sun's altitude and azimuth and I did that by computing ecliptic longitude of the Sun then converting the ecliptic longitude to right ascension and declination then I computed the sidereal time (degree) at Greenwich then local sidereal time at longitude then local hour angle then converting the hour angle and declination to altitude and azimuth  

---

## 2 answers

### Answer by username_3 on 2024-07-23. Score: 1 | Accepted answer

The time zone for the input to the equations is Universal Time (UT). The Universal Time is determined from the time on your clock ("local time") and the time offset from UTC=0.

* UT is used to calculate the Julian Day (along with the date).
* The Julian Day is used to calculate the Sun's ecliptic longitude. (This is then converted to right ascension and declination, assuming the Sun's ecliptic latitude is 0. :-)
* The Julian Day (along with your longitude) is used to calculate your local sidereal time (LST).
* The right ascension, declination, LST, and your latitude are used to calculate the altitude and azimuth.

In summary, the input is the date and time (in UT), latitude and longitude. The output is the Sun's altitude and azimuth.

> **Comments:**
> **username_0**: so I should convert the local time to UTC right? and is that equal to remove the offset from local time like if the local time = 15:23 and offset = +3 so the UTC = 12:23?  
> **username_3**: That is correct.  
> **username_0**: Thanks @JohnHoltz, but why was local time converted to UTC in the equations in the website I mentioned in the question?  
> **username_3**: UT is used to make the equations easier. If they were based on the local time, you would need X number of different equations: one for each time zone. It is easier for everyone to use the same equation and let them convert their time to UT.  
> **username_0**: And if I convert local time to UTC, will the altitude and azimuth values be accurate? I mean, sun altitude and azimuth would be correct at the local time of my choice? To clarify more, when I choose the time 11:23 as local time then converting it to UTC, it will be 8:23 and when calculating the altitude and azimuth then will these values be the same as the values of altitude and azimuth in my local time?  
> **username_3**: Yes. Alt and Az are based on the objects position (RA and Dec), sidereal time, and observer's location. The Sun's position is only correct when using UT. The sidereal time is correct when using UT because the calculation compensates for the time difference by using the longitude. Have you tried it yet? If not, why not? If so, did you get the correct result?  
> **username_0**: Yes, I tried it and got the correct result, but I'm trying to deal with the local time and UTC in different time zones. I will add a property for time offset within (-11, 11) and add the value to local time hours. I think that will have the same effect as converting the time to UTC by time zone ID. Is that correct?  

---

### Answer by username_4 on 2024-07-23. Score: 0

You should use *local* sideral time for calculations (again, I emphasize *local*, otherwise you will increase your work and over-complicate the entire process), then it is easy to convert the time you calculate into solar time then into other time zone like UTC+3

> **Comments:**
> **username_3**: Unless you have a sundial or an app that tells you the local solar time, how do you know what the local solar time is?  I think the OP needs to clarify what is meant by "compute the Sun's position". If they are using equations, the equations are based on a particular time zone (probably UTC or TT). The time zone must match the time used by the computation method.  
> **username_4**: @JohnHoltz, you calculate it through sidereal time which can be obtained by right ascension of the culminating celestial body  
> **username_4**: The equations are based on local sideral time (or hour angle if you prefer), not the solar time we use everyday.  
> **username_0**: I computed sidereal time at Greenwich then local sidereal time at the wanted longitude then local hour angle  
> **username_2**: You would use local sidereal time for computing the Alt/Az coordinates once you have RA/Dec coordinates.  Computing the RA/Dec coordinates would use something closer to TBD like UTC.  You'd also need something similar to UTC to compute the local sidereal time.  
> **username_5**: @AhmedDyaa I don't understand what you're asking. Sidereal time is almost always off by a number of minutes from the local time zone, and off from UTC by that same number of minutes plus the local time zone's offset. If you want to convert into either UTC or local clock-time, then you have to know that number of minutes and adjust your local sidereal to local time zone. You can then convert to UTC the usual way, if you want to.  
> **username_0**: @GregMiller I have the local sidereal time, first I did that by computing ecliptic longitude of the Sun then converting the ecliptic longitude to right ascension and declination then I computed the sidereal time (degree) at Greenwich then local sidereal time at longitude then local hour angle then converting the hour angle and declination to altitude and azimuth  

---

