Blog

Calculate Moon Rise and Set in PHP

If you've been paying attention to my Twitter account, you've probably seen a reference or two about how I've been calculating the positions of astronomical bodies. Well, today I release part of that to you.

Download: Source

The above code is pretty much a direct port of Keith Burnett's implementation here. Outside of porting, my only changes were some code clean up and having the timezone be calculated automatically for the longitude given. This means that you will always get back a time stamp that is local to the point of origin.

How to Use

Moon::calculateMoonTimes(month, day, year, latitude, longitude);

Code: php
  1. date_default_timezone_set('America/Chicago');
  2. include('moon.php');
  3. print_r(Moon::calculateMoonTimes(6, 28, 2011, 36.754478, -96.110291));
  4. ?>

The above code will output the following result:

Code: output
  1. stdClass Object ( [moonrise] => 1309246800 [moonset] => 1309300560 )

Moonrise and moonset, as stated previously, are a Unix time stamp local to the latitude and longitude given.

Make it open - The Tetras

The Tetra logo, courtesy of Don Kennedy

Tetra: [ Download ]

Tetra 2: [ Download ]

Picking up where I left off last time, we shall progress forward with my CMS releases.

After realizing that the core model of YPNgine seemed broken (looking back it may not have been, but whatever), I decided to scrap the entire project and go a completely different route. When I began conceptualizing this new CMS, there were a few things that I needed to consider from the very start: security and extensibility. With that, I began working on Tetra (named after the type of fish I had at the time).

Read More

Make it Open - YPNgine

YPN logo during the YPNgine era

YPNgine: Download

Sometime in 2003 I became the administrator of YPN. Not entirely sure why, but there it was. As all the other admins left, so went their involvement in the future engine of YPN, partyfish. For reasons I cannot remember, I too stopped development of partyfish even though it was near complete.

But, I didn't drop the idea of a new engine and leave YPN in the capable hands of sasq2 and phpBB. No, I began writing my own CMS: YPNgine. Even with just a handful of months of PHP experience, I'd tasked myself to create a multi-user CMS with various levels of administration, a document library and fully functional forum that needed, at least to the users, all the functionality of the old phpBB. No small task indeed.

But I pounded away at it no doubt learning many, many things along the way. I even opened it up to a public beta, though I cannot for the life of my think of where this was hosted (somewhere on an FSF server, no doubt).

Going through the changelog comments I left int the source files and performing a delta against the final post on this thread, YPNgine took somewhere in the range of two months to develop. I do remember quite keenly when I actually turned this thing live. The first week was nothing but bug reports and security issues. They all got squashed, but in the end between the issues and the requested features, I decided that the entire model I had built YPNgine around was unsustainable, but that's a story for a different day.

I am actually writing this post because I am releasing all of the source code from the last "build" of YPNgine to the public. You can use that link at the top, or download it here.