Discussion: Objective C Time & Date code

In case anyone is interested, I did a straight port of the PHP code for calculating the Glitch date and time to Objective C.  See below.  I think it's working correctly, but seem to keep coming up with an incorrect day.  The year, month, hour and minute are right, but the day seems off.    Take a look and tell me where I've gone wrong...

+(NSString *) server_date_time {
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    df.dateFormat = @"yyyy-MM-dd HH:mm:ss ZZZ";
    NSDate *startDate = [df dateFromString:@"2009-04-04 05:00:00 UTC"];
    NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0];
    NSArray *dayNames = [NSArray arrayWithObjects:@"Hairday", @"Moonday", @"Twoday", @"Weddingday", @"Theday", @"Fryday", @"Standday", @"Fabday", nil];
    NSArray *monthNames = [NSArray arrayWithObjects:@"Primuary", @"Spork", @"Bruise", @"Candy", @"Fever", @"Junuary", @"Septa", @"Remember", @"Doom", @"Widdershins", @"Eleventy", @"Recurse", nil];

    NSTimeInterval secs = [now timeIntervalSinceDate:startDate];int year = floor(secs / 4435200);
    secs -= year * 4435200;
    int day_of_year = floor(secs / 14400);
    secs -= day_of_year * 14400;
    int hour = floor(secs / 600);
    secs -= hour * 600;
    int minute = floor(secs / 10);
    secs -= minute * 10;int month_of_year = 0;
    int day_of_month = 0;
    int months[] = {29, 3, 53, 17, 73, 19, 13, 37, 5, 47, 11, 1};
    
    int cd = 0;
    for (int i=0; i<12; i++){
        cd += months[i];
        if (cd > day_of_year){
            month_of_year = i+1;
            day_of_month = day_of_year + 1 - (cd - months[i]);
            break;
        }
    }

    int days_since_epoch = day_of_year + (307 * year);
    int day_of_week = days_since_epoch % 8;
    NSString *ap = (hour >= 12)?@"pm":@"am";
    if (hour > 12) hour -= 12; NSString *sfx = @"th";
    NSString *dnum = [NSString stringWithFormat:@"%i", day_of_month];
    if ([dnum hasSuffix:@"1"])
        sfx = @"st";
    else if ([dnum hasSuffix:@"2"])
        sfx = @"nd";
    else if ([dnum hasSuffix:@"3"])
        sfx = @"rd";
    
    NSString *dayName = [dayNames objectAtIndex:day_of_week];
    NSString *monthName = [monthNames objectAtIndex:month_of_year];
    NSString *out = [NSString stringWithFormat:@"%i:%i %@, %@ %i%@ of %@, year %i", hour, minute, ap, dayName, day_of_month, sfx, monthName, year];
    NSLog(@"%@",out);
    return out;
}
BTW, excuse the formatting - not many options for code markup here.  :)
And just to summarize, with the existing code, I get the following date:
10:31 pm, Fryday 23rd of Doom, year 16
...but the server reports:
10:31 pm, Fabday 4th of Doom, year 16
Doh!  I think I've got it.  The docs state:
"1238562000, better known as 5am UTC on April 4th, 2009"

But if you do the conversion like so:
NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:1238562000];
... you end up with April 1st (is this a test to see who's reading closely?).

I was previously creating the date (4/4/2009 5:00:00), but when I use the numeric timestamp that is 4/1/2009, it sorta' works...except I'm now one month off.  By changing my code " month_of_year = i+1;" to " month_of_year = i;", it seems to be working correctly.