Friday, January 6, 2012

Friday 1-6-12

objective C, using NSDate class

int main (int argc, const char * argv[])
{

@autoreleasepool {

NSDate *now = [[NSDate alloc] init];
NSLog(@"The date is %@", now);

double seconds = [now timeIntervalSince1970];
NSLog(@"It has been %f seconds since the start of 1970.", seconds);

NSDate *later = [now dateByAddingTimeInterval:10000];
NSLog(@"In 10,000 seconds it will be %@", later);

NSDate *evenLater = [now dateByAddingTimeInterval:100000];
NSLog(@"In 100,000 seconds it will be %@", evenLater);

NSCalendar *cal = [NSCalendar currentCalendar];
NSUInteger day = [cal ordinalityOfUnit:NSDayCalendarUnit
inUnit:NSMonthCalendarUnit
forDate:now];
NSLog(@"This is day %lu of the month", day);


}
return 0;
}

No comments:

Post a Comment