Skip to content

Instantly share code, notes, and snippets.

@jinto
Created December 30, 2011 17:28
Show Gist options
  • Save jinto/1540699 to your computer and use it in GitHub Desktop.
Save jinto/1540699 to your computer and use it in GitHub Desktop.
days and hours from birth date
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[])
{
NSString *birthd = @"1971-8-24 09:00:00 +0900";
NSDate *from = [[NSDate alloc] initWithString:birthd];
NSTimeInterval diff = [from timeIntervalSinceNow];
int days = diff / 60 / 60 / 24;
int hours = ((int)diff/60/60) % 24;
printf("%d days and %d hours from %s\n", -days, -hours, [birthd UTF8String]);
return 0;
}
@jinto
Copy link
Author

jinto commented Dec 30, 2011

나도 이제 objective c 코더 ! 예이!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment