Listing 1764
Submitted by PHPRO.ORG, 17 November 2008
function getEquinox($year, $timezone='GMT') { switch ( $timezone ) { case 'GMT': /*** timestamp of March 20 2008, 7:30am GMT ***/ $timestamp = 1205958600; break; case 'UTC': /*** timestamp of March 20 2008, 5:48am UTC ***/ $timestamp = 1205952480; break; default: $timestamp = 1205958600; } /*** days in a year is 365*400+97)/400 = 365.2425 ***/ $seconds_in_year = 365.2425*24*60*60; /*** how many years since 2008 ***/ $num_years = $year - 2008; /*** seconds in $num_years ***/ $elapsed_seconds = $num_years*$seconds_in_year; /*** add base timestamp plus eleapsed seconds ***/ $next_equinox = $timestamp + $elapsed_seconds; return $next_equinox; } echo date('Y m d H m i', getEquinox(2009, 'GMT')); echo "<br />\n"; echo date('Y m d H m i', getEquinox(2009, 'UTC')); echo "<br />\n";
