Somacon.com: Articles on websites & etc.

§ Home > Index > Freeware

Moon Phases for PHP Script (CSV format)

Generate a list of Moon Phase dates and times for any year with this free online tool. The format is CSV, so you can use it in PHP script, Javascript, or any other programming language or database. The data comes directly from the U.S. Navy Astronomical Applications API for Phases of the Moon.

Moon Phase Generator

Enter a Year
Year must be between 1700 and 2100, inclusive.
Enter a single year like 2025,
or a range like 2025-2030.
Select a time zone
   

PHP Script

The PHP script to get the moon phases downloads the date/times from the U.S. Navy Astronomical Applications API in JSON format. It converts the date/times from UTC to the selected time zone. Then, it prints the data in multiple formats as separate columns of a CSV file. You can download the CSV file and open it in Excel.

The columns available are:

Developers

Please do not link directly to this data. It is not designed to be high performance and will slow down your application. Download the data and store it in your system.

Change Log

September 2024

Entering a range of years is fixed, and the file name includes the range if specified. The min/max year range is greatly increased to reflect the new capabilities of the API.

December 2022

I updated the page to use the new Moon Phases API provided by the U.S. Navy.

October 2019

This tool stopped working in 2019 when the old US Navy Moon Phases tool was removed. When I inquired about the outage, I received the following helpful and detailed response :

As of 24 October 2019 we had to shut down all of our web pages that contained active content (i.e. the online calculators) by order of one of our superior Commands due to new DoD cybersecurity rules. We are in the process of migrating our content to a more secure platform, and we anticipate that the sites will be restored on or about 31 October 2020.
A possible workaround for you might be MICA, USNO's standalone Windows Multi-year Interactive Computer Almanac. This software will replicate most of the various functions that we offered on our web pages.
MICA uses the same source code as the online calculators and the annual Astronomical Almanac. It is distributed by Willmann-Bell, Inc. More info can be found at https://www.willbell.com/almanacs/almanac_mica.htm.
An online calculation service is provided by our Almanac partner in the UK, Her Majesty's Nautical Almanac Office. The service is intended for personal non-commercial use. The URL is http://astro.ukho.gov.uk/.
Select the "Websurf 2.0" option and follow the prompts. While the location pages default to British cities, you can input your location/time zone or select a location from a map. The site supports a number of calculations that are similar to the ones that we had on our old site.
Geoffrey R Chester (CIV USN NAVOBSY DC), Public Affairs Officer, U.S. Naval Observatory, 9/8/2020


Have you heard of the new, free Automated Feeds offered by Google Merchant Center? Learn more in Aten Software's latest blog post comparing them to traditional data feed files.
Created 2011-12-04, Last Modified 2024-09-04, © Shailesh N. Humbad
Disclaimer: This content is provided as-is. The information may be incorrect.