# What is the formula to input date, time and longitude. Where I can get latitude of the civil twilight back?

I am making a watch app, where I need to know where there is currently sun, and where it's not.

I need to have some sort of formula/function to insert: date, time and longitude, and get back the latitude of the civil twilight.

How can I do this?

• Could you maybe explain it a bit clearer? As far as I understand, you want to draw an area on the world map where there is currently civil twilight. But you must know that such area isn't a line, but is an area, so you would get inequation. The places in civil twilight have Sun between -6° and 0° of altitude. Commented Jun 22, 2021 at 18:54
• Yes, well, i dont really need it to be that specific. the worldmap is 200px x 100px, as it is going to be shown on a wristwatch. I just want to make something with this kind of effect, just way smaller: i.ytimg.com/vi/fDJrih_rAUc/maxresdefault.jpg Commented Jun 22, 2021 at 21:43
• How will this factor in the height above sea level of the observer? It's still sunny on a mountaintop when the Sun has set for those on the plain... (I'm sure there's a deeper philosophical meaning here!). Commented Jun 22, 2021 at 22:58
• Related: astronomy.stackexchange.com/q/39670/16685 My answer there has Python code that calculates sunrise time, and it can be modified to compute sunset time, if you understand the Equation of Time. However, that code uses a very crude formula for the Sun's position, I have a more accurate formula here: astronomy.stackexchange.com/a/40243/16685 Commented Jun 23, 2021 at 3:06
• BTW, calculating the exact time of sunrise, sunset, and the various twilights is tricky. As chappo mentioned, you need to take the local geography into account, and atmospheric refraction, which is rather large for celestial bodies near the horizon. Commented Jun 23, 2021 at 3:12