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

1. Aug 22, 2004

### Goats Dont Shave

Hello Everyone,

I put this message on the astronomy forum but didn't really get the answear I was looking for.

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?

I am not really a big maths person so please try and keep your answears as simple as you can.

If anybody thinks that I have posted this message in the wrong place please say.

Thanks for any help anybody might have.

2. Aug 22, 2004

### HallsofIvy

3. Aug 26, 2004

### Moonbear

Staff Emeritus
Sunrise and sunset aren't changed by fixed amounts every day. It's more of a sine function, less of a daily change near each equinox, and more rapid changes in daylight hours nearer the solstices. When I need sunrise/sunset times, I just go to the US Naval Observatory website for information (they also include more detailed information than most sites about twilights, which is important for me to know as well). Sorry I can't help you more than that.

4. Aug 26, 2004

### Integral

Staff Emeritus
Moonbear,
You are correct it is nearly sinusoidal, but. Sorry to nit pick. Day length change rate is greatest at the equinox's and least at the solstice. Right now (end of Aug) we have started the ramp leading to short days. By mid Nov. day length will be near the minimum and will stay near the same till mid Jan.

IMHO, The seasons are not correctly timed. Winter and Spring are the season of ever increasing day length, summer and Fall Decreasing day length. I think Summer ought to be days of maximum length and little change, May, Jun & Jul, Fall is the season of diminishing day length Aug, Sept, &Oct. Winter is the season of short days Oct, Nov, & Jan. Spring the season of growing day length, Feb, Mar, & Apr.

Note that your local sunrise sunset times will also be determined by your local horizon. I have been in valleys were even in summer the sun did not get above the horizon until 10-11am, and sat by 2-3pm. Any computations will tell you the time the sun crosses the perfect horizon.

5. Aug 26, 2004

### Moonbear

Staff Emeritus
Oops...I knew that, just wrote it backward. Hope it didn't confuse anyone! I got myself preoccupied trying to figure out the correct plural of equinox (equinoxes, equinoces?) and then wrote the wrong thing.