...その作業コード
NSDate *testDate=[NSDate date];
NSDateFormatter *formatterNew = [[NSDateFormatter alloc] init];
[formatterNew setDateFormat:@"dd-MM-yyyy HH:mm:ss "];
NSString *dt = [formatterNew stringFromDate:testDate];
NSString *strDateTaken=dt;
NSLog(@"Date=%@",strDateTaken);
[formatterNew release]; // This line can be removed if you are using ARC
NSDateFormatter *tempFormatter = [[[NSDateFormatter alloc]init]autorelease];
[tempFormatter setDateFormat:@"dd-MM-yyyy HH:mm:ss"];
NSDate *toDate = [tempFormatter dateFromString:strDateTaken];
NSLog(@"Current Date ==%@",toDate);
NSDateFormatter *tempFormatter1 = [[[NSDateFormatter alloc]init]autorelease];
[tempFormatter1 setDateFormat:@"dd-MM-yyyy HH:mm:ss"];
NSDate *startdate = [tempFormatter1 dateFromString:@"30-08-2011 16:25:00"];
NSLog(@"Last Date ==%@",startdate);
int i = [startdate timeIntervalSince1970];
int j = [toDate timeIntervalSince1970];
double X = j-i;
int days=(int)((double)X/(3600.0*24.00));
NSLog(@" Difference :%d",days);
いいえ、実際の時間は2011年1月20日午前6時51分35秒0000とローカルの時間です2011-01-20 12:21:35 +0530です。あなたの現地時間はGMT –
のように+0000になるでしょう。それが役に立ったら開発者が協力して助けてくれるように答えを受け入れるべきです。 – Aditya
[NSDate date]はGMT0で現在の日時を返します? –