Sun and Moon Calculations

Please enable JavaScript to use this page.

Copyright © Peter Hayes 2001-2012
Last Updated on 2011:12:23
Report moon phase at 00:00 and 24:00.
Change the 4 moon phases to 00:00 rather than noon.
Updates to sun_moon.html.

If you want rise and set times at your location you can add a query string to this URL, it should look something like these examples

Cheltenham in Summer ?Place='Cheltenham'&Lat=51.88&Long=-2.12&TZ=+1&TZname='BST'
Berlin ?Place='Berlin'&Lat=+52.53&Long=13.42&TZ=+1&TZname='CET'
Stockholm ?Place='Stockholm'&Lat=59.332&Long=18.062&TZ=+1&TZname='CET'
Washington DC ?Place='Washington%20DC'&Lat=+38.88&Long=-77.0&TZ=-5&TZname='EST'

The Universal Time date and time above depends on your computer having the correct date, time and timezone set.

The sun rise and set calculations are based on the method in the sci.astro newsgroup FAQ by Paul Schlyter. They should be within a few minutes of the correct time except at high latitudes.

The moon rise, set and phase calculations use the methods in Astronomical Algorithms by Meeus. A phase of 360° is a full moon, it reduces to 180° at new moon and 0° at the next full moon. The table for the phases uses the larger of Meeus's corrections and agrees with the tables of moon phases at The US Naval Observatory. Meeus calculates the times using terrestrial dynamic time (TDT). TDT = UTC + (number of leap seconds) + 32.184 At the end of 2008 the 24th leap second was added but when a leap second is added is un-predictable as it depends on difference between the variable rotation of the Earth and the precise 'tick' of an atomic clock. So here the correction from TDT to UTC is currently correct to the end of 2010. This should still be sufficient for those religions which use a lunar calendar as the local moonrise depends on things such as the local horizon and light pollution which affects when the first sighting of the new moon is possible, see the USNO Islamic page for more details.

If you want to add sun or moon details to your pages for non-commercial use you may copy the JavaScript and any of these web pages. You must keep my copyright notice in the source. I accept no liability for any errors if you use the code. Please contact me for commercial use, to report problems and to suggest improvements, my e-mail address is on my home page.

If you use Internet Explorer you can use the File->Save As option and select the type Web Page, complete to save this page and all its other files. But Internet Explorer does not save the text 'as is' but makes un-necessary changes. I recomment you right click on the following links and select the Save Target As option. I keep the JavaScript and style sheet in a directory called library. If you save it somewhere else you will need to correct the web pages.

clock.js contains some time & date utilities.
degrees.js contains additional maths library routines.
astro.js contains general astronomical functions.
sun.js contains the Sun calculations.
moon.js contains the moon calculations.
sun_moon.html contains the source of the main Sun and Moon page.
default.css contains the style sheet for the web pages.

I also have some ephemeris pages which calculate an ephemeris for the sun, moon or planets.

To contact me look at the contact me section in my home page.

I can also recommend The Photographers Ephemeris which has a nice map interface for selecting a location.