// Get server timestamp
$today = time();
// Get number of days from today until the end of this year
$rest_of_year = date('z', mktime(0,0,0,12,31,date('Y', $today))) - date('z', $today);
// Get number of days from the 1st of 2004 to election day
$election = date('z', mktime(0,0,0,11,2,2004));
// Add the days remaining in this year to the number of days in 2004 prior to election day
$countdown = $rest_of_year + $election;
It seems clear enough that they're making a mistake in the calculation.
I think it should be:
$countdown = $election - ($length_of_year - $rest_of_year);
or more simply:
$countdown = $election - $today;
(where $length_of_year is calculated using the date function).
Checking:
July 31 is the 213th day of the year, so 153 days remain (leap year and all that) in the year. Election day is November 2, 306 days from the start of the year and 59 days from the end of the year, so the net is 153 - 59 = 94 days (or 93+ days). To get -153 days, they must have taken 153 - 306 days.
The coder apparently got mixed up in knowing whether s/he was counting from the first or the end of the year.
Or something like that.
Cheers,
Scott.