# Formula for sunset/rise times, moonrise/set and phases

1. Aug 21, 2004

### Goats Dont Shave

Hello Everyone,
I am currently designing project where part of it will involve a website and amoungst things, on the site I would like present the time for sunrise and set for the current day and the same for moonrise and set as well as the current lunar phase. This is for a college project and I would prefer if someone could give me a formula/algorithm for any of them. I know there is code out there on the net but I can't just copy and paste this. I would feel comfortable writing the code to carry out any of the formulas you might have.

I think the formulas are probably quite difficult but would it not be true that the sunrise and sunset time will change by a fixed amount each day. for example if i know the sunrise time for my location on 1 august 2004 is it just a matter of adding on a certain amount of minutes and seconds each day until a certain date when the it will begin to rise earlier? this is probably a bit too good to be true?

Could the same apply for moonrise/set times?

Would the same type of method apply for the lunar phases? We know that the moon orbits earth every 29.6 days so is it just a matter of working out when the last full moon was, lets say it was 1 august we now know that next one will be 29.6 days later. so if someone comes along on august 15 the program could then work out the percentage of the moon showing and give a good estimate of the phase. similarily if someone comes along in december then the program could start from 1 august and then calculate the phase and % for that day. Does anybody think this would work or is there an accurate formula out there?

Also does anybody know when darkness officailly starts? how long after sunset? same for twilight, dawn etc?

Thanks for any help anybody might have.

PS i hope I posted this on the correct forum. If you think it is better suited to one of the maths forum please say.
Thanks again
goats

2. Aug 21, 2004

Staff Emeritus
The sunrise and sunset times depend on the latitude. The simplest way is to calculate time of local apparent noon and length of apparent day from the astronomical triangle with sun's declenson (by date, from ephemeris) and colatitude as two of the legs and 180o (noon) as the included angle, using the spherical trig cosine theorem. The third leg will be the hour angle, from which the time can be calculated. Then you subtract half the day length from noon to get the raw sunrise time and adding it to get raw sunset time. Then these have to be corrected for refraction, etc (a fixed calc), and there you are. The Moon times are MUCH more difficult, and probably should be calculated from finite differences.

3. Aug 21, 2004