Sun and Moon Calculations

Note: This is a mirror copy of the original web page, uploaded with permission of Peter Hayes

Please enable JavaScript to use this page.

Copyright © Peter Hayes 2001-2015
Last Updated on 2015:06:30
New leap second at midnight 30 June 2015.
Update to moon.js comments in 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, the link in the first column will show it in your browser.

Arctic Circle ?Place='Arctic Circle'&Lat=66.563&Long=0&TZ=0&TZname='UT'
Equator ?Place='Equator'&Lat=0&Long=0&TZ=0&TZname='UT'
Antarctic Circle ?Place='Antarctic Circle'&Lat=-66.563&Long=0&TZ=0&TZname='UT'
Stonehenge ?Place='Stonehenge'&Lat=51.1789&Long=-1.8264&TZ=0&TZname='GMT'
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. UK Lighting Up Time is defined as 30 minutes after sunset to 30 minutes before sunrise.

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 June 2015 the 26th 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 for 26 leap seconds. 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, contact me at my e-mail address.

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.

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

 

This web page was last updated 08/21/18